简体   繁体   English

如何在基于某些行记录数据加载时禁用 extJS 网格中的网格单元

[英]How to disable grid cell in extJS grid while loading base on some row record data

How to disable grid cell in extJS grid while loading base on some reacid data.如何在基于某些 reacid 数据加载时禁用 extJS 网格中的网格单元。

I am using grid where I want to disable one grid editor based on record data.我正在使用网格,我想根据记录数据禁用一个网格编辑器。 Here what I am trying but what happening is when any of the cell is getting disable entier column cellis getting disable.这是我正在尝试的,但发生的是当任何单元格被禁用时,整个列单元格被禁用。

My clumn definaation我的粗俗定义

{
    "header": "column 3",
    "tdCls":"editable-grid-cell",
    "dataIndex": "clumn3",
    "width":120,
    "renderer":"enableDisablecolumn3",
    "editor": {
      "xtype": "numberfield", 
      "bind": "{record.column3}",
      "disabled":false,
      "allowDecimals":true,     
      "decimalPrecision":5,
      "allowNegative": false,
      "maskRe": "/[0-9.-]/",
      "minValue": 0 
    }
}

My renderer methos.我的渲染器方法。

enableDisablecolumn3:  function(value, metaData, record) {
        //debugger;
        let _this = this;
        var gridEditor = metaData.column.getEditor();
        if ('Yes' === record.data.column2&& ) {    
            gridEditor.setDisabled(true);    
        }
    } 

Any idea how to achive this.任何想法如何实现这一点。 I want disable only that perticular cell.我只想禁用那个特定的单元格。

You can use beforeedit event.您可以使用 beforeedit 事件。 Something like this:像这样的东西:

Ext.application({
    name: 'Fiddle',

    launch: function () {
        Ext.create('Ext.data.Store', {
            storeId: 'simpsonsStore',
            fields: ['name', 'email', 'phone'],
            data: [{
                name: 'Lisa',
                email: 'lisa@simpsons.com',
                phone: '555-111-1224'
            }, {
                name: 'Bart',
                email: 'bart@simpsons.com',
                phone: '555-222-1234'
            }, {
                name: 'Homer',
                email: 'homer@simpsons.com',
                phone: '555-222-1244'
            }, {
                name: 'Marge',
                email: 'marge@simpsons.com',
                phone: '555-222-1254'
            }]
        });

        Ext.create('Ext.grid.Panel', {
            title: 'Simpsons',
            store: Ext.data.StoreManager.lookup('simpsonsStore'),
            columns: [{
                header: 'Name',
                dataIndex: 'name',
                editor: 'textfield'
            }, {
                header: 'Email',
                dataIndex: 'email',
                flex: 1,
                editor: {
                    completeOnEnter: false,
                    field: {
                        xtype: 'textfield',
                        allowBlank: false
                    }
                }
            }, {
                header: 'Phone',
                dataIndex: 'phone'
            }],
            selModel: 'cellmodel',
            plugins: {
                cellediting: {
                    clicksToEdit: 1
                }
            },
            height: 200,
            width: 400,
            listeners: {
                beforeedit: function( editor, context, eOpts ) {
                    if(context.field === 'name' && context.value === "Marge") {
                        return false;
                    }
                }
            },
            renderTo: Ext.getBody()
        });
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM