我的页面中有一个网格,上面有一个CheckboxModel。它显示了名称和复选框,但我不知道如何将商店中的布尔列绑定到选择模型中的列。我找到了使用CheckColumn的示例,但是这会抛出一个错误,它没有构造函数。必须是v4的变化。非常感谢您的帮助。
Ext.define('Roles', {
extend: 'Ext.data.Model',
fields: ['Id', 'Name', 'Selected'],
proxy: {
type: 'ajax',
url: '/tpn/Types/AjaxList',
reader: {
type: 'json',
root: 'rows',
totalProperty: 'total',
successProperty: 'success'
},
listeners: {
exception: function (proxy, type, action, options, response, arg) {
Ext.MessageBox.alert('Error', Ext.decode(type.responseText).error);
}
}
}
});
var roleStore = Ext.create('Ext.data.Store', {
model: 'Roles'
});
var sm = Ext.create('Ext.selection.CheckboxModel');
var grid = Ext.create('Ext.grid.Panel', {
store: roleStore,
selModel: sm,
columns: [{
header: 'Name',
dataIndex: 'Name',
flex: 1
}],
renderTo: 'RoleGrid',
autoHeight: false,
height: 200,
frame: false
});
答案 0 :(得分:2)
您可以在网格的 afterrender 事件(或绑定商店的加载事件)上放置一个侦听器,以便遍历商店以获取布尔选中的值,调用 GridPanel.selectRecords()方法来选择UI中的所有这些记录。这将检查他们的复选框。