[英]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 ,上面写着:
fireEvent canceledit
fireEvent
canceledit
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.