2

我的页面中有一个网格,上面设置了 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
});

在此处输入图像描述

4

1 回答 1

2

您可以在网格的afterrender事件(或绑定存储的加载事件)上放置一个侦听器,以遍历存储以获取布尔检查值,并调用GridPanel.selectRecords()方法来选择 UI 中的所有这些记录。这将检查他们的复选框。

于 2011-06-22T13:47:08.540 回答