sencha gridpanel checkbox 复选框的勾选 以及和单机行冲突
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', {
checkOnly: true //防止单击行的时候,其他选中的checkbox被取消选中
})
}
复选框的勾选
在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
作者:xuejianxiyang
出处:http://xuejianxiyang.cnblogs.com
关于作者:Heaven helps those who help themselves.
本文版权归原作者和博客园共有,欢迎转载,但未经原作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。