[英]Extjs4, how to restore edited grid cell value in edit function?
我需要在編輯功能中恢復(設置值到編輯前的值)編輯的網格單元格值,而不是在validateedit函數中。
"orderList": {
validateedit: function (plugin, edit) {
//validate...
},
edit: function (plugin, edit) {
Ext.MessageBox.confirm('Confirm', 'Are you sure to change this order status?', function (btn) {
if (btn == 'yes') {
//update
} else {
// I want to rollback!
edit.cancel = true;
edit.record.data[edit.field] = edit.originalValue; //it does not work
}
});
}
}
如何更改網格單元格值(編輯器)?
謝謝!
拒絕方法怎么樣:
"orderList": {
validateedit: function (plugin, edit) {
//validate...
},
edit: function (plugin, edit) {
Ext.MessageBox.confirm('Confirm', 'Are you sure to change this order status?', function (btn) {
if (btn == 'yes') {
//update
} else {
edit.record.reject(); // this should revert all changes
}
});
}
}
另請注意, edit
事件的第二個參數(您命名為“edit”的參數)不包含cancel
屬性,即beforeedit
事件的屬性。 所以這行edit.cancel = true
不會為你做任何事情。
我也很好奇為什么你沒有使用beforeedit
事件,它似乎更適合這種事情 - 它為什么它有cancel
屬性。
如果綁定到網格上的afteredit
事件,則可以執行以下操作,具體取決於您要重置的粒度。
注意 :我沒有添加任何邏輯來保持快速和直截了當。
grid.on('afteredit', function(e) {
e.record.set(e.field, e.originalValue);
}
grid.on('afteredit', function(e) {
e.record.reject();
}
grid.on('afteredit', function(e) {
e.grid.store.rejectChanges();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.