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

Hide checkcell on render - extjs 6.5.3 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) : '';
        }
    }

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

基于this answer of mine,当您将覆盖添加到您的代码时,您可以使用以下内容:

Ext.util.CSS.createStyleSheet('.hideCheck .x-grid-checkcolumn::after { content: \'\' }');
Ext.create('Ext.grid.Panel', {
    columns: [{
        xtype:'checkcolumn',
        updateMeta: function(v, meta, record) {
            if(v===null) meta.tdCls = "hideCheck";
        }

Relevant fiddle

您可以使用 gridcell and inside gridcell you can use checkbox 来实现您的要求。

在此 FIDDLE 中,我使用 gridcellcheckbox 创建了一个演示。我希望这会 help/guide 你达到你的要求。

代码片段

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
        });
    }
});

一种可能性是使用单元格的隐藏 属性。

提示:此 属性 标记为 private!

{   
    xtype: 'grid',
    store: store,

    itemConfig: {
        viewModel: true
    },

    columns: [{
        xtype: 'checkcolumn',
        text: 'Boolean',
        dataIndex: 'bool',
        width: 200,
        cell: {
            hideMode: 'visibility',
            bind: {
                hidden: '{!record.bool}'
            }
        },
    }]
}

Fiddle

                            <Renderer  Handler="if(record.data.Field !== null && record.data.Field.length &gt; 0){
                                      return true;
                                               }else{
                                      return false;
                                                } "/>