当我点击取消时,如何让extjs中的rowediting插件不添加行?

wou*_*non 5 javascript extjs extjs4.2 extjs-grid roweditor

目前该rowediting插件提供了选项update/cancel.当我按下cancel按钮时,如果它是新添加的行,我希望它不添加新行.

我怎样才能做到这一点?

这是FIDDLE.

目前,有了rowediting,我只是添加和删除行.如果无法使用cancel,如何添加新按钮close并使其不添加行.

我也在查看sencha论坛,我找到了一个POST,其中说明如下:

  1. fireEvent canceledit

  2. 如果autoRecoverOnCancel是真的,如果记录是幻影然后删除它

但是,这也行不通.你能建议吗?

var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
    clicksToMoveEditor: 1,
    autoCancel: false,

});

tbar: [{
    text: 'Add Employee',
    iconCls: 'employee-add',
    handler: function() {
        rowEditing.cancelEdit();

        // Create a model instance
        var r = Ext.create('Employee', {
            name: 'New Guy',
            email: 'new@sencha-test.com',
            start: new Date(),
            salary: 50000,
            active: true
        });

        store.insert(0, r);
        rowEditing.startEdit(0, 0);
    }
}, {
    itemId: 'removeEmployee',
    text: 'Remove Employee',
    iconCls: 'employee-remove',
    handler: function() {
        var sm = grid.getSelectionModel();
        rowEditing.cancelEdit();
        store.remove(sm.getSelection());
        if (store.getCount() > 0) {
            sm.select(0);
        }
    },
    disabled: true
}]
Run Code Online (Sandbox Code Playgroud)

Dar*_*lev 4

这里您可以看到如何取消未保存的记录:

var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
    clicksToMoveEditor: 1,
    //autoCancel: false,
    listeners:{
        'canceledit': function(rowEditing, context) {
            // Canceling editing of a locally added, unsaved record: remove it
            if (context.record.phantom) {
                context.store.remove(context.record);
            }
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

您的小提琴示例不起作用,因为您正在使用 ExtJS 4.0.0。在这里你可以找到一个可以使用 ExtJS 4.2.0 的版本:jsfiddle