ExtJs 使用点滴 十四 通过设置CheckboxSelectionModel属性值来实现GridPanel复选框可用不可用

var sm = new Ext.grid.CheckboxSelectionModel({singleSelect : false,renderer:function(v, p, record)
                        {
                       
                       
                          if (record.get('ITEMNAME') == '总计:'){  
                               return '';  
                          }  
                          return '<div class="x-grid3-row-checker"> </div>';                        
                        },
                      onHdMouseDown : function(e, t) {  
                          if (t.className == 'x-grid3-hd-checker') {  
                               e.stopEvent();  
                               var hd = Ext.fly(t.parentNode);  
                               var isChecked = hd.hasClass('x-grid3-hd-checker-on');  
                               if (isChecked){  
                                  hd.removeClass('x-grid3-hd-checker-on');  
                                  this.clearSelections();  
                              }else {  
                                  hd.addClass('x-grid3-hd-checker-on');  
                                  if (this.locked){  
                                      return;  
                                  }  
                                  this.selections.clear();  
                                  for (var i = 0, len = this.grid.store.getCount(); i < len; i++ ){  
                                      if (this.grid.store.getAt(i).data["ITEMNAME"] != '总计:'){  
                                           this.selectRow(i, true);  
                                      }  
                                 }  
                              }  
                         }  
                      },                        
                  handleMouseDown : function(g, rowIndex, e){  
                        if (e.button !== 0 || this.isLocked()) {  
                               return;  
                        }  
                        var view = this.grid.getView();  
                        if (e.shiftKey && !this.singleSelect && this.last != false ) {  
                             var last = this.last;  
                             this.selectRange(last, rowIndex, e.ctrlKey);  
                             this.last = last;  
                             view.focusRow(rowIndex);  
                        }else{  
                             var isSelected = this.isSelected(rowIndex);  
                             if (e.ctrlKey && isSelected) {  
                                  this.deselectRow(rowIndex);  
                             }else if(!isSelected || this.getCount() > 1){  
                                  if(this.grid.store.getAt(rowIndex).data["ITEMNAME"] != '总计:'){  
                                      this.selectRow(rowIndex, e.ctrlKey || e.shiftKey);  
                                  }  
                                  view.focusRow(rowIndex);  
                             }  
                        }  
                  }                                       
             });

上一篇:@ResponseBody返回json时,json数据丢失或者报错


下一篇:最全的iOS数据存储方法