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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值