本文介绍了extjs编辑器网格更新栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新编辑器网格中显示的记录。而不是更新相同的记录,一个新的记录被插入到数据库...我在哪里缺少?pllzz帮助。以下是我的JsonStore代码: / p>
Ext.data.Api.restActions = {
create:'POST',
read:'GET ',
update:'PUT',
destroy:'DELETE'};
ProdStore = Ext.extend(Ext.data.JsonStore,{
constructor:function(cfg){
cfg = cfg || {};
ProdStore。 superclass.constructor.call(this,Ext.apply({
storeId:'ProdStore',
id:'ProdStore',
url:'products.json',
root :'proddata',
restful:true,
idProperty:'id',
successProperty:'success',
autoLoad:true,
autoSave:false,
批次:true,
作者:新Ext.data.JsonWriter({
encode:false,
listful:false,
writeAllFields:false}),
字段:[
{name:'customer_id'},{name:'prodnm'},
{name:'qty'},{name:'rate'},{name :'amt'}
]
},cfg));
}
});
new ProdStore();
解决方案
商店中设置的idProperty应该是表示数据库中的唯一行。在这种情况下可能是customer_id?
如果这不能解决问题,我将不得不看到后端代码来查看如何处理保存。 >
i am trying to update records displayed in editor grid..but instead of updating same record, a new record gets inserted into the database...what am i missing??pllzz help..following is my JsonStore code :
Ext.data.Api.restActions = {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy : 'DELETE' };
ProdStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
ProdStore.superclass.constructor.call(this, Ext.apply({
storeId: 'ProdStore',
id:'ProdStore',
url: 'products.json',
root: 'proddata',
restful:true,
idProperty:'id',
successProperty:'success',
autoLoad:true,
autoSave:false,
batch:true,
writer: new Ext.data.JsonWriter({
encode: false,
listful: false,
writeAllFields: false}),
fields: [
{ name:'customer_id'},{ name: 'prodnm'},
{ name: 'qty'}, { name: 'rate' }, { name: 'amt'}
]
}, cfg));
}
});
new ProdStore();
解决方案
The idProperty set on the store should be the field that represents unique rows in the database. Perhaps customer_id in this case?
If this does not fix the issue, I would have to see the back end code to see how the save is being handled.
这篇关于extjs编辑器网格更新栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!