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

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

问题描述

我正在实现一个网格面板,其中最后四列可以编辑大部分行。问题是,我希望能够禁用编辑,假设record.get('status')= 4,并且只有两列应该是可编辑的,那么我们假设第一个。



是否有办法禁用显示这些行的编辑?我可以使用CellEditing来做,但想继续使用RowEditing插件。



问候,
Kristian

解决方案

使用 beforeedit 事件:

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

更新

上述解决方案无效for rowEditor。

但是,您可以在 beforeedit 之前禁用必要的字段。要做到这一点,你应该可以访问rowediting插件。将pluginId分配给插件:

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

现在只需禁用必要的字段:

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

这里是 (试着编辑第一行)。

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


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.

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.

Regards, Kristian

解决方案

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.

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

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