Ext.define('saas.override.grid.column.CheckColumn', {
override: 'Ext.grid.column.Check',
/**
* 是否switch模式
*/
switch: false,
switchOffCls: Ext.baseCSSPrefix + 'grid-switchcolumn',
switchOnCls: Ext.baseCSSPrefix + 'grid-switchcolumn-checked',
constructor: function (config) {
config = config || {};
if (config.switch) {
config.checkboxCls = this.switchOffCls;
config.checkboxCheckedCls = this.switchOnCls;
}
this.scope = this;
this.callParent([
config
]);
},
defaultRenderer: function (value, cellValues, a, b, c, d, e, f) {
var me = this,
cls = me.checkboxCls,
tip = '';
if (me.invert) {
value = !value;
}
if (me.disabled) {
cellValues.tdCls += ' ' + me.disabledCls;
}
if (value) {
cls += ' ' + me.checkboxCheckedCls;
tip = me.checkedTooltip;
} else {
tip = me.tooltip;
}
if (tip) {
cellValues.tdAttr += ' data-qtip="' + Ext.htmlEncode(tip) + '"';
}
if (me.useAriaElements) {
cellValues.tdAttr += ' aria-describedby="' + me.id + '-cell-description' + (!value ? '-not' : '') + '-selected"';
}
// This will update the header state on the next animation frame
// after all rows have been rendered.
me.updateHeaderState();
if (typeof value == 'object' && value == null) {
cellValues.style = 'display: none;';
cellValues.tdCls += ' ' + me.disabledCls;
cellValues.innerCls = me.disabledCls;
cellValues.classes.push(me.disabledCls);
cellValues.cellRole = me.disabledCls;
return ''
}
//hideCheckField hideCheckVal
//根据 某个字段 判断该行的checkbox 是否要隐藏 ,后期可拓展
if (e.selModel && e.selModel.hideCheckField) {
var field = e.selModel.hideCheckField;
var checkVal = e.selModel.hideCheckVal;
if (a.get(field) == checkVal) {
cellValues.style = 'display: none;';
cellValues.tdCls += ' ' + me.disabledCls;
cellValues.innerCls = me.disabledCls;
cellValues.classes.push(me.disabledCls);
cellValues.cellRole = me.disabledCls;
return ''
}
}
return '';
},
updater: function (cell, value) {
var me = this,
tip;
if (me.invert) {
value = !value;
}
if (value) {
tip = me.checkedTooltip;
} else {
tip = me.tooltip;
}
if (tip) {
cell.setAttribute('data-qtip', tip);
} else {
cell.removeAttribute('data-qtip');
}
if (me.useAriaElements) {
me.updateCellAriaDescription(null, value, cell);
}
cell = Ext.fly(cell);
cell[me.disabled ? 'addCls' : 'removeCls'](me.disabledCls);
Ext.fly(cell.down(me.getView().innerSelector, true).firstChild)[value ? 'addCls' : 'removeCls'](me.checkboxCheckedCls);
// This will update the header state on the next animation frame
// after all rows have been updated.
me.updateHeaderState();
}
});