ExtJS 4 RowEditing disable edit on one column based on record

前端 未结 3 1942
夕颜
夕颜 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:28

    Use beforeedit event:

    grid.on('beforeedit', function(editor, e) {
      if (e.colIdx === 0 && e.record.get('status') == 4)
        return false;
    });
    

    UPDATE
    The solution above is not working for rowEditor.
    However you can make needed field to be disabled on beforeedit. To do that you should be able to access rowediting plugin. Assign pluginId to plugin:

    plugins: [
        Ext.create('Ext.grid.plugin.RowEditing', {
            clicksToEdit: 1,
            pluginId: 'rowEditing'
        })
    ],
    

    Now just disable needed field if some conditions are met:

    grid.on('beforeedit', function(editor, e) {
        if (e.record.get('status') === 4 ){
             grid.getPlugin('rowEditing').editor.form.findField('fieldToDisable').disable();
        }
        else{
            grid.getPlugin('rowEditing').editor.form.findField('fieldToDisable').enable();
       });
    

    Here is demo (try to edit first row).

    Edit

    If the above JSFiddle does not work, try its updated version.

提交回复
热议问题