简体   繁体   English

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

[英]How can I make the rowediting plugin in extjs to not add a row when I hit cancel?

Currently the rowediting plugin gives the option of update/cancel . 当前, rowediting插件提供了update/cancel选项。 When I hit the cancel button if it is a newly added row, I would like it to not add the new row. 当单击cancel按钮(如果它是新添加的行)时,我希望它不添加新行。

How can I achieve this? 我该如何实现?

Here is the FIDDLE . 这是FIDDLE

Currently, with the rowediting , I am just adding and removing the rows. 当前,通过rowediting ,我只是添加和删除行。 If it is not possible using cancel , how can I add a new button close and make it not add the row. 如果无法使用cancel ,如何close新按钮并使其不添加行。

I was also looking at sencha forums and I found a POST where it says the following: 我也在看sencha论坛,发现一个POST ,上面写着:

  1. fireEvent canceledit fireEvent canceledit

  2. when autoRecoverOnCancel is true, if record is phantom then remove it autoRecoverOnCancel为true时,如果记录为幻像,则将其删除

But, that didn't work, either. 但是,那也不起作用。 Could you suggest? 你能建议吗?

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
}]

Here you can see how to cancel the non-saved records: 在这里,您可以查看如何取消未保存的记录:

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

Your fiddle example doesn't work, because you are using there ExtJS 4.0.0. 您的小提琴示例不起作用,因为在那里使用的是ExtJS 4.0.0。 Here you can find a working one with ExtJS 4.2.0: jsfiddle 在这里,您可以找到使用ExtJS 4.2.0的可行版本: jsfiddle

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在网格(EXTJS)中从跨行到行? - how can i make it from span to row in grid(EXTJS)? 如何编辑此代码,以便在提示框为空或单击取消时可以使程序检测是否未输入成绩? - How can I edit this code so that I can get the program to detect if no grades were entered when the prompt box is empty or cancel is hit? 如何在 ExtJs 中突出显示文本? - How can I make texts highlightable in ExtJs? 使用行编辑器进行编辑时,如何在extjs 4.1.1中禁用行的特定单元格? - How can I disable a particular cell of a row in extjs 4.1.1 when edit using row editor? 如何使搜索仅在按 Enter 键时才起作用? - How I make the search only work when I hit enter? 当我遇到它重新启动的障碍时,我将如何添加一个事件 - How would i add a event when i hit the obstacle it restarts Extjs手风琴项目如何点击它时如何使一个打开的项目不再关闭 - Extjs accordion items how can i make an open item not to close again when clicking on it 当我在文本框中输入单词并按空格键时,如何将输入的单词变成一个单独的短语,如何创建文本框? - How can I create a text box when I enter words in text box and hit spacebar it has to make entered words into a separate phrase? 我可以以此为依据吗? - Can I make a hit counter from this? 为什么当我在“确认”对话框中单击“取消”时,JS Confirm()不会取消提交动作? - Why JS confirm() won't Cancel the submit action when I hit Cancel in confirm dialog?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM