首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Ext.grid.GridPanel不需按住Ctrl键单元行多选成效实现

2012-11-08 
Ext.grid.GridPanel不需按住Ctrl键单元行多选效果实现项目中遇到需要实现在Ext.grid.GridPanel中选中单元

Ext.grid.GridPanel不需按住Ctrl键单元行多选效果实现
项目中遇到需要实现在Ext.grid.GridPanel中选中单元格时,不需要按ctrl键便可多选,后来在sencha论坛上找到下面方法:重写Ext.grid.CheckboxSelectionModel中的handleMouseDown方法,该方法继承自Ext.grid.RowSelectionModel(),然后调用重写后的方法定义sm即可

Ext.override(Ext.grid.CheckboxSelectionModel, {     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; // reset the last           view.focusRow(rowIndex);         }else{           var isSelected = this.isSelected(rowIndex);           if(isSelected){             this.deselectRow(rowIndex);           }else if(!isSelected || this.getCount() > 1){             this.selectRow(rowIndex, true);             view.focusRow(rowIndex);           }         }       } });  var sm = new Ext.grid.CheckboxSelectionModel();

热点排行