2015-09-23 38 views
0

下面是在網格編輯器中有一個按鈕的可執行代碼片段。我需要按鈕出現在編輯器中,但是我不需要按鈕的任何值來更新。編輯器的更新功能似乎不再適用。任何想法我可能會失蹤?ExtJs(4.2.0)帶xtype:按鈕列的可編輯網格

Ext.create('Ext.data.Store', { 
    storeId:'EmployeeData', 
    fields:['name', 'email', 'phone'], 
    data: [ 
     {"name":"aaa", "email":"[email protected]", "phone":"987654321"}, 
     {"name":"bbb", "email":"[email protected]", "phone":"987654321"}, 
     {"name":"ccc", "email":"[email protected]", "phone":"987654321"}, 
     {"name":"ddd", "email":"[email protected]", "phone":"987654321"} 
    ]}); 

var grid = Ext.create('Ext.grid.Panel', { 
    title: 'Employee', 
    store: Ext.data.StoreManager.lookup('EmployeeData'), 
    columns: [ 
     {header: 'Name', dataIndex: 'name', editor: 'textfield'}, 
     {header: 'Email', dataIndex: 'email', flex:1, 
      editor: { 
       xtype: 'textfield', 
       allowBlank: false 
      } 
     }, 
     {header: 'Phone', dataIndex: 'phone'}, 
     {header: 'button', dataIndex:'',editor:{xtype:'button',editable: false}} 
    ], 
    selType: 'rowmodel', 
    plugins: [ 
     Ext.create('Ext.grid.plugin.RowEditing', { 
      clicksToEdit: 1, 
      pluginId: 'rowEditing' 
     }) 
    ], 
    height: 200, 
    width: 400, 
    renderTo: Ext.getBody() 
}); 
+0

它鬆散的代碼應該產生一個4行4列的網格。你在期待什麼? – Joe

+0

如果您碰巧閱讀了說明,它說因爲有一列xtype按鈕,編輯器不起作用。 – user997805

+0

你可以在小提琴中運行這個。由於xtype按鈕列,編輯器不起作用。 – user997805

回答

0

編輯器使用每個x-fieldgetValue()功能,按鈕控制不具備getValue()功能,因此它拋出異常,並沒有更新記錄。

也許你可以使用ActionColumn如果它可以滿足你的目的。你可以像處理按鈕一樣附加處理函數。

相關問題