有没有办法使 ExtJS4 PropertyGrid (Ext.grid.property.Grid) 不可编辑?
没有“可编辑”或“只读”配置选项 AFAICS。
另一种解决方案是添加一个侦听器,以防止启动编辑组件:
listeners: {
'beforeedit': {
fn: function () {
return false;
}
}
}
此解决方案的问题是,无法标记要复制 (Ctrl+C) 内容的单元格。
使用 将sourceConfig
编辑器设置为Ext.form.DisplayField
:
Ext.create('Ext.grid.PropertyGrid', {
sourceConfig: {
field1: {
displayName: 'Editable Field'
},
field2: {
displayName: 'Readonly Field',
editor: Ext.create('Ext.form.DisplayField')
}
},
source: {
field1: "Some property",
field2: "Some other property",
}
});
还有一个决定,但此后不允许选择文本:myGrid.findPlugin('cellediting').disable();
一种解决方案是防止选择任何单元格:
var myPropertyGrid = Ext.create('Ext.grid.property.Grid', { ... });
myPropertyGrid.getSelectionModel().setLocked(true);
Ext.define('MyPropertyGrid', {
extend: 'Ext.grid.property.Grid',
xtype: 'mypropertygrid',
source: {
field1: 'value of field1',
field2: 'value of field2'
},
sourceConfig: {
field1: {
editor: {disabled: true}
},
field2: {
editor: {disabled: true}
}
}
});
我在 Extjs 6.0 上测试它。