2012-11-01 23 views
3

有沒有辦法讓ExtJS4 PropertyGrid(Ext.grid.property.Grid)不可編輯?只讀PropertyGrid

沒有「可編輯」或「只讀」配置選項AFAICS。

+0

我還沒有嘗試過,但有一個禁用的配置,默認爲false,請嘗試將其設置爲true? – Amalea

+0

@Amalea不錯的主意,但它只是完全禁用了這個東西,給出了一個空的灰色面板(正如你所期望的我猜) –

+0

......實際上沒有,它顯示的屬性,但在半透明的灰色面具下。它應該工作,如果我能以某種方式擺脫那個面具 –

回答

0

一種解決方案是,以防止任何小區的選擇:

var myPropertyGrid = Ext.create('Ext.grid.property.Grid', { ... }); 
myPropertyGrid.getSelectionModel().setLocked(true); 
5

另一種解決方案是增加一個監聽器,其防止在開始編輯部分:

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

的問題與這種解決方案是,不能將單元格標記爲複製(Ctrl + C)內容。

1

使用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", 
    } 
}); 
1

還有一個決定,但不允許在其後選擇文本:myGrid.findPlugin('cellediting').disable();

+0

這在extjs 6.5.3中爲我工作。我在afterrender事件處理程序中進行了調用。 – costa

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 。

+0

儘管這段代碼可能會回答這個問題,但最好包含一些_context_,解釋_how_它的工作原理和_when_使用它。從長遠來看,僅有代碼的答案是沒有用的。 –