具有新记录的Store.sync()不会导入服务器生成的字段作为响应 [英] Store.sync() with new record does not import server-generated fields in response
问题描述
这是网格控制器的摘录:
doneEdit:function(editor,e,eOpts){
var me = this;
//
//在更新期间设置加载掩码(如果记录更改并有效)
//
if(e.record.dirty& ;& e.record.isValid()){
e.grid.showUpdatingMask(); (
e.store.sync
}
else {
me.cancelEdit(editor,e,eOpts);
}
$,
//
// onSaveSuccess()仅用于行编辑器网格
//
onSaveSuccess:function (批次,选项){
var me = this,
grid = me.getGrid();
grid.getStore()。filter([]); //重新运行任何已存在的过滤器,并进行排序。
grid.hideMask();
//更新只读活动存储,如果由子类指定
if(me.activeStore){
// $ TODO:handle load failure
me .activeStore.load();
}
},
我有同样的问题(Ext 4.2.1)。原因是我忘了设置idProperty在读者默认是id,我的是_id。 Ext无法更新记录,因为它无法识别匹配的ID。现在它的作用就像一个魅力。
所以确保响应是读者期望的正确格式(根,idProperty,模型定义,...) p>
I have a grid with row-editing enabled. When I add a row and call store.sync(), the server generates certain fields on that record, and returns the full record info in the response. However, ExtJS does not seem to update its copy of the record, except for the id. Is there a way to make it do that, or do I need to write custom code?
This is an excerpt of the grid's controller:
doneEdit: function (editor, e, eOpts) {
var me = this;
//
// Set up loading mask on grid during update (if record changed and is valid)
//
if (e.record.dirty && e.record.isValid()) {
e.grid.showUpdatingMask();
e.store.sync({
success: me.onSaveSuccess,
failure: me.onSaveFailure,
scope: me
});
}
else {
me.cancelEdit(editor, e, eOpts);
}
},
//
// onSaveSuccess() is only used for row editor grids
//
onSaveSuccess: function (batch, options) {
var me = this,
grid = me.getGrid();
grid.getStore().filter([]); // re-run whatever filters already exist, and sort.
grid.hideMask();
// update read-only active store if specified by sub-class
if(me.activeStore) {
// $TODO: handle load failure
me.activeStore.load();
}
},
I had the same problem (Ext 4.2.1). The reason was that I forgot to set the idProperty on the reader default is "id", mine is "_id". Ext silently failed to update the record because it didn't recognize a matching id. Now it works like a charm.
So make sure the response is in the correct format expected by your reader (root, idProperty, model definition, ...)
这篇关于具有新记录的Store.sync()不会导入服务器生成的字段作为响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!