不允许编辑Ext propertygrid字段

  如何禁止对ext的propertygrid的字段进行编辑。

 

  对于禁止编辑ext propertygrid的所有字段,可以有2种方法

1)配置 :true(Ext版本2.3.0+),所有字段无法编辑,propertygrid显示为灰色的。

不允许编辑Ext propertygrid字段

var propsGrid = Ext.create('Ext.grid.property.Grid', {
    disabled :true,//....propertygrid其他配置
});

2)使用beforeedit事件(Ext版本4.1+以上),return false阻止对ext propertygrid的编辑

不允许编辑Ext propertygrid字段

var propsGrid = Ext.create('Ext.grid.property.Grid', {
    listeners: { beforeedit: function () { return false } },//propertygrid其他配置
});

 

  如果只是不允许编辑某些字段的内容,可以使用beforeedit事件,判断当前编辑的字段名称,然后返回true/false,示例不允许编辑grouping和created2个字段的值。

不允许编辑Ext propertygrid字段   不允许编辑Ext propertygrid字段

var propsGrid = Ext.create('Ext.grid.property.Grid', {
  listeners: { beforeedit: function (editor, e) { console.log(e); return ',grouping,created,'.indexOf(','+e.record.data.name.toLowerCase()+',') == -1; } }
//....propertygrid其他配置
});

 

加支付宝好友偷能量挖...


原创文章,转载请注明出处:不允许编辑Ext propertygrid字段

评论(1)Web开发网
阅读(581)喜欢(0)extjs开发技巧