通过设置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">&#160;</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);   
                             }   
                        }   
                  }                                        
             });
posted @ 2012-06-05 14:20  angus_csh  阅读(2294)  评论(0编辑  收藏  举报