Extjs在ColumnModel下使用CheckboxSelectionModel,多選失效,只能單選

最近開始使用Extjs進(jìn)行開發(fā), 會(huì)遇到一些各種各樣的問題, 在此希望記錄下來, 給和我一樣新入手人一點(diǎn)提示.

問題: 在ColumnModel下添加復(fù)選框, 添加完成之后, 此復(fù)選框只能單選, 沒辦法同時(shí)選中多個(gè)選項(xiàng).

前期代碼如下:
this.colModel = new Ext.grid.ColumnModel({
columns : [this.rowNum
,
new Ext.grid.CheckboxSelectionModel(),
{
dataIndex : 'ID',
singleSelect : false
}
}
this.aGrid = new Ext.grid.EditorGridPanel(
{
id : 'aGrid',
title : 'Category Definition',
region : 'center',
height : 250,
autoScroll : true,
store : this.aStore,
selModel : new Ext.grid.CheckboxSelectionModel({
singleSelect : false}),
colModel : this.aGrid,
view : this.gridView,
stripeRows : true,
enableDragDrop : true,
SelectionMemory : 'Disabled',
ddGroup : 'aGridDDGroup',
.............................................
}

經(jīng)過多方查證, 都顯示只要將屬性"singleSelect : false", 就意味著允許多選 , 但實(shí)際上還不可以. 尚不能確定是由于Extjs版本的問題引起的, 還是多控件組合使用導(dǎo)致的相互作用. 最后發(fā)現(xiàn)可以使用"checkOnly: true" 來解決這個(gè)問題.

代碼如下:

selModel : new Ext.grid.CheckboxSelectionModel({ singleSelect : false,
checkOnly: true}),

var selectionModel = this.assetGrid.getSelectionModel();

操作完成之后, 清除已經(jīng)選中的items:

selectionModel.clearSelections()

獲取被選中的多個(gè)item的對(duì)象:

var str = '';
var selectRows = categorySelectionModel.getSelections();
for(var i=0;i <selectRows.length;i++){
str = str + selectRows[i].get('ID') + ',';
}
alert(str);

對(duì)于checkboxSelectionModel,不再顯示提示框:

listeners : {
'cellclick' : this.openNewApp,
scope : this,
render : function(grid) {
var view = grid.getView();
grid.tip = new Ext.ToolTip(
{
target : view.mainBody,
delegate : '.x-grid3-cell',
trackMouse : true,
renderTo : document.body,
anchor : 'top',
listeners : {
beforeshow : function updateTipBody(tip) {
var rowIndex = view
.findRowIndex(tip.triggerElement);
var cellIndex = view
.findCellIndex(tip.triggerElement);
if(cellIndex == 0 ){
tip.body.dom.setDisplayed(false)
}else if (cellIndex < 5 || cellIndex > 7) {
var cell = view.getCell(
rowIndex, cellIndex);
tip.body.dom.innerHTML = cell.innerHTML;
} else {
tip.body.dom.innerHTML = 'xxxxxxx';
}
}
}
});
},

我的checkbox放在第一列, 所以cellIdex是0, 當(dāng)它為0時(shí),設(shè)置setDisplayed為false,可以讓這一列沒有提示框.

tip.body.dom.setDisplayed(false)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容