在渲染上隐藏checkcell - extjs 6.5.3现代

时间:2018-04-25 07:14:11

标签: javascript extjs grid extjs6-modern

如果其他checkcell的值为checkcolumn,我正试图隐藏column的{​​{1}}。但不幸的是,根据sencha docs 只有在单元格类型是Ext.grid.cell.Cell的默认值时才会处理此配置。

所以使用null配置的解决方案将无效。

例如:

renderer

要实现这一目标的任何提示或技巧?

4 个答案:

答案 0 :(得分:2)

您可以使用gridcell,在gridcell内,您可以使用checkbox来满足您的要求。

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

CODE SNIPPET

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

答案 1 :(得分:1)

基于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

答案 2 :(得分:0)

可能是使用单元格的 hidden 属性。

提示:此属性标记为私有

{   
    xtype: 'grid',
    store: store,

    itemConfig: {
        viewModel: true
    },

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

Fiddle

答案 3 :(得分:0)

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