ExtJS 4 RowEditing disable edit on one column based on record

前端 未结 3 1941
夕颜
夕颜 2021-02-01 18:55

I\'m implementing a grid panel with the four last columns editable for most of the rows. The problem is that I\'d like to be able to disable editing on, let\'s say the first one

3条回答
  •  失恋的感觉
    2021-02-01 19:16

    Since @Molecular Man answer makes the disabled column look kinda funny when rowediting is editing I thought of another way that looks perfect. All you have to do is create a function, that may be for example:

    function fieldFormat() {
        if(isGuest) {
            return null; //is not editable
        } else {
            //how you want the column's field config to be formated
            var json = Ext.JSON.decode("{xtype: 'textfield',maxLength: 40}");
            return json;
        }
    }
    

    and in the grid, you put something like this:

    var grid = Ext.create('Ext.grid.Panel', {
        plugins: [grid_rowEditing],
        store: store,
        columns: [
        {
            text     : 'Name',
            dataIndex: 'name',
            field    : fieldFormat()
        }]
    });
    

    and when isGuest is true the field 'name' won't be editable. When it's false, it will be editable

提交回复
热议问题