5

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

我怎样才能做到这一点?

这是FIDDLE

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

我也在看煎茶论坛,我发现了一个帖子上面写着以下内容:

  1. 火灾事件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
}]
4

1 回答 1

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);
            }
        }
    }
});

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

于 2014-05-02T19:05:31.730 回答