简体   繁体   English

使用行编辑器进行编辑时,如何在extjs 4.1.1中禁用行的特定单元格?

[英]How can I disable a particular cell of a row in extjs 4.1.1 when edit using row editor?

How can I disable a particular cell of a row when edit in extjs 4.1.1? 在extjs 4.1.1中进行编辑时,如何禁用行的特定单元格? i am using gridrow editor. 我正在使用gridrow编辑器。 I have a grid which has 2 columns, name and age. 我有一个网格,其中有2列,名称和年龄。 When click for edit I have to disable the name field, the user can only edit age. 当单击以进行编辑时,我必须禁用名称字段,用户只能编辑年龄。

If you can only edit using the row editor, then don't specify the editor config on the column. 如果只能使用行编辑器进行编辑,则不要在列上指定编辑器配置。 If you can add too, then you could try the following ( I haven't ever done it myself, but it should work) : 如果也可以添加,那么您可以尝试以下操作(我自己从未做过,但是应该可以):

grid.on('beforeedit', function(editor, e, eOpts) {
     // if editing.. 
     this.down('column[dataIndex=name]').setEditor(null);
     // else
     this.down('column[dataIndex=name]').setEditor(/* editor config */);
}, grid);

You can use this 你可以用这个

grid.on('beforeedit', function(editor, e, eOpts) {
         // if editing.. 
         if(e.field == "name"){
               e.cancel = true;  
          }
    });

Setting e.cancel as true will disable the field from editing. 将e.cancel设置为true将禁用该字段的编辑。

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

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