Dojo Grid 一列中同時有checkbox 和數據的實現 和 設置checkbox 可用與不可用(disable) 的方法

前景:

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;'}
]]}
];

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章