转:Ext GridPanel根据条件显示复选框

Ext GridPanel实现复选框选择框:

var selectModel = new Ext.grid.CheckboxSelectionModel({
     singleSelect : false
});

但是这样每一行都会有复选框,如果需求为:某行数据的某个列满足什么条件我才有复选框选项就不太好实现了,

这样就需要重写Ext.grid.CheckboxSelectionModel的渲染,行点击涵数来实现.

1 var selectModel = new Ext.grid.CheckboxSelectionModel({
 2       singleSelect : false,
 3       renderer : function(v, p, record){
 4           if (record.data['结果状态'] == '0'){
 5                return '';
 6           }
 7           return '<div class="x-grid3-row-checker">&#160;</div>';
 8       },
 9       onHdMouseDown : function(e, t) {
10           if (t.className == 'x-grid3-hd-checker') {
11                e.stopEvent();
12                var hd = Ext.fly(t.parentNode);
13                var isChecked = hd.hasClass('x-grid3-hd-checker-on');
14                if (isChecked){
15                   hd.removeClass('x-grid3-hd-checker-on');
16                   this.clearSelections();
17               }else {
18                   hd.addClass('x-grid3-hd-checker-on');
19                   if (this.locked){
20                       return;
21                   }
22                   this.selections.clear();
23                   for (var i = 0, len = this.grid.store.getCount(); i < len; i++ ){
24                       if (this.grid.store.getAt(i).data["结果状态"] != '0'){
25                            this.selectRow(i, true);
26                       }
27                  }
28               }
29          }
30       },
31       handleMouseDown : function(g, rowIndex, e){
32             if (e.button !== 0 || this.isLocked()) {
33                    return;
34             }
35             var view = this.grid.getView();
36             if (e.shiftKey && !this.singleSelect && this.last != false ) {
37                  var last = this.last;
38                  this.selectRange(last, rowIndex, e.ctrlKey);
39                  this.last = last;
40                  view.focusRow(rowIndex);
41             }else{
42                  var isSelected = this.isSelected(rowIndex);
43                  if (e.ctrlKey && isSelected) {
44                       this.deselectRow(rowIndex);
45                  }else if(!isSelected || this.getCount() > 1){
46                       if(this.grid.store.getAt(rowIndex).data["结果状态"] != '0'){
47                           this.selectRow(rowIndex, e.ctrlKey || e.shiftKey);
48                       }
49                       view.focusRow(rowIndex);
50                  }
51             }
52       }
53 });

原文:

http://fordream.iteye.com/blog/1179252

 

转载于:https://www.cnblogs.com/glsqh/p/6185801.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值