grid增加checkbox列
1 Ext.apply(this, { 2 id: "userrolegrid", 3 width: 700, 4 height: 500, 5 selType: 'rowmodel', 6 selModel: new Ext.selection.CheckboxModel(),//复选框模板 7 columns: [ 8 { text: '角色名称', dataIndex: 'NAME', flex: 1, align: 'center' } 9 ], 10 store: Ext.create('App.store.RoleStore'), 11 buttons: [{ 12 action: 'userrole_save_button', 13 iconCls: 'icon-submmit', 14 text: '确定' 15 }, { 16 action: 'userrole_cancel_button', 17 iconCls: 'icon-remove', 18 text: '取消' 19 }] 20 });
加载的时候选中已经存在的列,在store里面监听load事件
1 listeners: { 2 load: function (store, opration) { 3 var userID = Ext.getCmp('usergrid').getSelectionModel().getSelection()[0].data.ID; 4 var sm = Ext.getCmp('userrolegrid').getSelectionModel(); 5 var records = [];//存放选中记录 6 Ext.Ajax.request({ 7 url: '/OLXD/COC/User/GetListByUserID', 8 method: 'post', 9 params: { 10 userID: userID, 11 }, 12 success: function (response, options) { 13 var arr = Ext.decode(response.responseText); 14 for (var i = 0; i < arr.length; i++) { 15 records.push(store.findRecord('ID', arr[i].ROLE_ID)); 16 } 17 sm.select(records);//执行选中记录 18 }, 19 failure: function () { 20 Ext.msg.show('提示', '调用出错'); 21 } 22 }) 23 } 24 }