gridpanel顯示checkbox: 添加SelectionModel為Checkbox Selection Model { xtype: 'gridpanel', id: 'Grid1', header: false, title: '條線列表', deferRowRender: false,
gridpanel顯示checkbox:
添加SelectionModel為Checkbox Selection Model
{
xtype: 'gridpanel',
id: 'Grid1',
header: false,
title: '條線列表',
deferRowRender: false,
forceFit: true,
store: 'NewTiaoXianStore',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'Id',
text: 'Id'
},
{
xtype: 'gridcolumn',
dataIndex: 'Name',
text: '條線名稱'
},
{
xtype: 'gridcolumn',
dataIndex: 'Description',
text: '條線描述'
}
],
selModel: Ext.create('Ext.selection.CheckboxModel', {
})
}
覆選框的勾選
在load回調中根據欄位checked值判斷是否勾選
var store=Ext.getStore("Store");
store.proxy.extraParams={method:"GetList"};
store.load({
callback:function(records, options, success){
for(var i in records)
{
if(records[i].data.checked)
{
Ext.getCmp("Grid1").getSelectionModel().select(records[i],true); //勾選該記錄
}
}
}});
//grid根據行號(從0開始)選中
//第一個參數可以是行號或者records合集,第二個參數true表示保持之前勾選的(追加)
Ext.getCmp("Grid1").getSelectionModel().select(rowIndex,true);
From:http://www.cnblogs.com/xuejianxiyang/p/5220397.html