ExtJS 4 RowEditing 禁用基于记录的一列编辑 [英] ExtJS 4 RowEditing disable edit on one column based on record

查看:16
本文介绍了ExtJS 4 RowEditing 禁用基于记录的一列编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现一个网格面板,其中最后四列可对大多数行进行编辑.问题是我希望能够禁用编辑,假设第一个 if record.get('status') = 4 已完成,并且只有两列应该是可编辑的.

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 if record.get('status') = 4 which is finalized and only two of the columns should be editable.

有没有办法禁止显示这些行的编辑?我可以使用 CellEditing 来做到这一点,但我想继续使用 RowEditing 插件.

Is there a way to disable showing the edit for those rows? I can do it using CellEditing but want to keep using the RowEditing plugin.

问候,克里斯蒂安

推荐答案

使用 beforeedit 事件:

Use beforeedit event:

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

更新
上述解决方案不适用于 rowEditor.
但是,您可以在 beforeedit 上禁用所需的字段.为此,您应该能够访问行编辑插件.将 pluginId 分配给插件:

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

这是demo(尝试编辑第一行).

Here is demo (try to edit first row).

编辑

如果上述 JSFiddle 不起作用,请尝试其更新版本.

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

这篇关于ExtJS 4 RowEditing 禁用基于记录的一列编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆