如何将复选框列添加到 ExtJS 5 网格?

How do I add checkbox column to ExtJS 5 grid?

我想为我的 extjs 网格添加一个复选框 (true/false)。 当我尝试添加 xtype 的项目时:'checkbox' 我得到一个错误:

Uncaught TypeError: column.isColumnHidden is not a function

我在 post 上看到有一个复选框列的插件需要下载并包含在 ExtJS 中,ExtJS 5 中没有内置选项用于网格中的复选框?

当我使用复选框时,我从官方网站下载 extjs 库并通过 extjs 控制台构建 if 的开发版本。

我的带有复选框的 extjs 网格是这样的:

{
    xtype:'checkcolumn',
    fieldLabel: 'checkbox_label',
    name: 'checkbox_name',
    text: 'text'
}

因此完整的网格代码将如下所示:

{
    xtype: 'grid',
    frame: true,
    title: 'Users',
    collapsible: true,
    height: 250,
    bind: '{depGrid.selection.users}',
    columns: [
        {
            text: 'Id',
            dataIndex: 'id'
        },
        {
            text: 'Name',
            dataIndex: 'name'
        },
        {
            xtype:'checkcolumn',
            fieldLabel: 'checkbox_label',
            name: 'checkbox_name',
            text: 'text'
        }
    ]
}

您还可以尝试添加到复选框 dataIndex 字段并为其设置模型中的一些布尔变量。祝你好运!