3

有没有办法使 ExtJS4 PropertyGrid (Ext.grid.property.Grid) 不可编辑?

没有“可编辑”或“只读”配置选项 AFAICS。

4

5 回答 5

5

另一种解决方案是添加一个侦听器,以防止启动编辑组件:

    listeners: {
        'beforeedit': {
            fn: function () {
                return false;
            }
        }
    }

此解决方案的问题是,无法标记要复制 (Ctrl+C) 内容的单元格。

于 2013-02-15T13:19:26.270 回答
2

使用 将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",
    }
});
于 2013-09-20T22:35:42.773 回答
2

还有一个决定,但此后不允许选择文本:myGrid.findPlugin('cellediting').disable();

于 2014-10-15T14:02:09.157 回答
0

一种解决方案是防止选择任何单元格:

var myPropertyGrid = Ext.create('Ext.grid.property.Grid', { ... });
myPropertyGrid.getSelectionModel().setLocked(true); 
于 2012-11-02T14:56:45.363 回答
0
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 上测试它。

于 2016-03-14T03:08:42.913 回答