在一个grid列表中加入一个CheckboxSelectionModel,怎么样设置才能在页面显示时默认已经选中其中几项?应用场景:
在用户角色管理中,当前用户仅有角色列表中的部分角色,用户有的角色都要置为选中状态。
代码:
var sm = new Ext.grid.CheckboxSelectionModel({
singleSelect: false
});
var columns = [
{
header:'角色名称',
width:200,
dataIndex:'name',
sortable: true,
editor: new Ext.form.TextField()
},{
header:'描述',
width:200,
dataIndex:'descn',
sortable: true,
editor: new Ext.form.TextField()
},{ header:"选择",
width:80,
dataIndex: "id",
sortable: true,
editor: new Ext.form.Checkbox()
},sm
];
var roleCM = new Ext.grid.ColumnModel(columns);
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", webContext+'/sysManage/userRoleAction.do?methodCall=findRoles', false);
conn.send(null);
var data = Ext.util.JSON.decode(conn.responseText);
var roleStore = new Ext.data.JsonStore({
root: 'roles',
data: data,
fields: ['name', 'descn', 'id'],
autoLoad: true
});
this.grid = new Ext.grid.GridPanel({
id:'roleEditGrid',
store: roleStore,
cm: roleCM,
sm: sm,
trackMouseOver:false,
loadMask: true,
height:'auto',
autoScroll:true
});
除了这种方法,还有没有别的方法,能够将当前用户的角色信息勾选出来?
相关截图:
相关附件:
user.rar