Ext.grid.EditorGridPanel列表复选框不能随意多选的问题
生活随笔
收集整理的這篇文章主要介紹了
Ext.grid.EditorGridPanel列表复选框不能随意多选的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題
今天碰到這樣一個急手的問題:用這個Ext.grid.EditorGridPanel不能隨意多選,而且點擊復選框沒有反應。
我用的版本是3.4
解決
重寫CheckboxSelectionModel中的handleMouseDown 方法:
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); } } } });這樣就解決了,隨意多選的問題,然后可以不用按ctrl也可以多選。
Ext.grid.EditorGridPanel的使用如下:
var sm = new Ext.grid.CheckboxSelectionModel();
Ext.grid.EditorGridPanel({
sm:sm
cm:cm
});
var cm = new Ext.grid.ColumnModel(
[
new Ext.grid.RowNumberer(),
sm,
{id: ‘id’, header: “標題”, dataIndex: ‘title’, width: 320 },
{header: “文本”, dataIndex: ‘text’, width: 200 }
]);
特別注意:
在cm中, new Ext.grid.RowNumberer()和sm的前后順序必須是這樣的,否則復選框點擊無反應,這地方坑了我一個上午。
總結
以上是生活随笔為你收集整理的Ext.grid.EditorGridPanel列表复选框不能随意多选的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DOS控制台启动方式+DOS控制台常用命
- 下一篇: 背包九讲----02完全背包问题