javascript - 在渲染时隐藏检查单元 - extjs 6.5.3 modern

标签 javascript extjs grid extjs6-modern

如果另一个 column 的值为 null,我试图隐藏一个 checkcolumncheckcell。但不幸的是根据sencha docs 仅当单元格类型为默认的 Ext.grid.cell.Cell 时才处理此配置。

因此使用renderer 配置的解决方案将不起作用。

例如:

{
        xtype: 'checkcolumn',
        dataIndex: 'isSomething',
        text: '',
        width: 30,
        menuDisabled: true,
        headerCheckbox: false,
        renderer: function(value, record) {
            var relatedValue = record.get('somethingElse');
            return relatedValue ? new Ext.grid.column.Check().renderer(value) : '';
        }
    }

有什么提示或技巧可以实现吗?

最佳答案

你可以使用 gridcellgridcell 中你可以使用 checkbox达到您的要求。

在这个 FIDDLE ,我使用 gridcellcheckbox 创建了一个演示。我希望这会帮助/指导您实现您的要求。

代码片段

Ext.application({
    name: 'Fiddle',

    launch: function () {
        Ext.create({

            xtype: 'grid',

            title: 'Tree Grid Demo',

            // itemConfig: {
            //     viewModel: true
            // },

            store: {

                fields: [{
                    name: 'isCheck',
                    defaultValue: true
                }],
                data: [{
                    firstname: "Michael",
                    lastname: "Scott",
                    seniority: 7,
                    department: "Management",
                    hired: "01/10/2004"
                }, {
                    firstname: "Dwight",
                    lastname: "Schrute",
                    seniority: 2,
                    department: "Sales",
                    hired: "04/01/2004"
                }, {
                    firstname: "Jim",
                    lastname: "Halpert",
                    seniority: 3,
                    department: "Sales",
                    hired: "02/22/2006"
                }, {
                    firstname: "Kevin",
                    lastname: "Malone",
                    seniority: 4,
                    department: '',
                    hired: "06/10/2007"
                }, {
                    firstname: "Angela",
                    lastname: "Martin",
                    seniority: 5,
                    department: "Accounting",
                    hired: "10/21/2008"
                }]
            },

            columns: [{
                text: 'First Name',
                dataIndex: 'firstname'
            }, {
                text: 'Last Name',
                dataIndex: 'lastname'
            }, {
                text: 'Hired Month',
                dataIndex: 'hired'
            }, {
                text: '',
                width: 30,
                renderer: function (value, record, index, cell) {
                    if (record.get('department')) {
                        cell.setTools({
                            xtype: 'checkbox',
                            checked: record.get('isCheck')
                        });
                    } else {
                        return '';
                    }
                }

                /*cell: {
                    tools: {
                        xtype: 'checkbox',
                        bind: {
                            hidden: '{!record.department}',
                            checked: '{record.isCheck}'
                        }
                    }
                }*/
            }],

            fullscreen: true
        });
    }
});

关于javascript - 在渲染时隐藏检查单元 - extjs 6.5.3 modern,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50016174/

相关文章:

wpf - 在 WPF 中以编程方式设置带有 * 的网格列的宽度

css - 在 gwt 页面中设置一个相邻的网格

javascript - 为什么我会收到 JavaScript 运行时错误 : Expected ')' when I'm adding a client-side event to a dynamically generated button?

javascript - 当循环变量传递给回调函数时 undefined variable

php - extjs 4 : filling model data into combobox from PHP + MySql

javascript - 简单地从商店中检索所有记录

php - 升级 Extjs 3.3 到最新版本

javascript - AngularJS 和浏览器

异步函数中的Javascript全局变量?

css - 更改位置网格