前景:
Grid同一列中包含有checkbox 和数据。(一般情况checkbox和数据分别占据一列)
checkbox的check状态,disable状态,以及紧接checkbox后面的数据都来自store中的数据。
实现方法:
自定义类select.editors.Bool,继承dojox.grid.editors.Bool
dojo.declare("select.editors.Bool", [dojox.grid.editors.Bool], {
format: function(inDatum, inRowIndex){
var rowDatum = this.cell.grid.model.getRow(inRowIndex);
if(rowDatum && rowDatum[this.cell.textAttr]){
var disabled;
if(rowDatum[this.cell.disableAttr])disabled='disabled';
else disabled='';
return '<input '+ disabled +' class="dojoxGrid-input" type="checkbox"' + (inDatum ? ' checked="checked"' : '') + ' style="width: auto" />'+rowDatum[this.cell.textAttr];
}
},
doclick: function(e){
if(e.target.tagName == 'INPUT'){
this.applyStaticValue(e.rowIndex);
}
}
});
// 表头定义(使用自定义类select.editors.Bool)
var structure = [
{cells: [[
{name:'列名称1',
field:"checkFlag",
disableAttr:'disabledFlag',
textAttr:'textStr',
editor :select.editors.Bool,
styles :'text-align:left;height:33px;padding-center:18px;',
width:'170px'
},
{name:'列名称2',field:"name2",width: '108px',styles :'text-align:left;height:33px;padding-top:18px;'}
]]}
];