ExtJs(4.2.0)带有xtype:按钮列的可编辑网格

时间:2015-09-23 04:09:45

标签: javascript extjs extjs4.2 extjs-grid

下面是一段可执行的代码,在网格的编辑器中有一个按钮。我需要按钮出现在编辑器中,但是我不需要任何值的/来自按钮进行更新。编辑器的更新功能似乎不再起作用。知道我可能缺少什么吗?

Ext.create('Ext.data.Store', {
    storeId:'EmployeeData',
    fields:['name', 'email', 'phone'],
    data: [
        {"name":"aaa", "email":"aaa@emp.com", "phone":"987654321"},
        {"name":"bbb", "email":"bbb@emp.com", "phone":"987654321"},
        {"name":"ccc", "email":"ccc@emp.com", "phone":"987654321"},
        {"name":"ddd", "email":"ddd@emp.com", "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()
});

2 个答案:

答案 0 :(得分:0)

编辑器在每个getValue()上使用x-field函数,按钮控件没有getValue()函数,因此它抛出异常而无法更新记录。

如果它可以满足您的目的,也许您可​​以使用ActionColumn。您可以像处理按钮一样附加处理函数。

答案 1 :(得分:0)

有点晚了,但是我遇到了同样的问题。

您可以添加一个getValue方法,以使更新操作正常运行。

editor: {
    xtype: 'button',
    getValue: function() {
        return true;
    }
}
相关问题