2015-09-23 37 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如果它可以满足你的目的。你可以像处理按钮一样附加处理函数。

相关问题