|
-
我使用JsonWriter做资料更新,一直不成功,有人可以帮帮我吗?
var reader = new Ext.data.JsonReader({
root: 'rows',
totalProperty: 'total',
successProperty: 'success',
idProperty: 'prg_no',
fields: ['prg_no', 'prg_name', 'prg_spec', 'upduser', 'upddate', 'updtime']
});
var writer = new Ext.data.JsonWriter({
encode: false,
writeAllFields: true
});
var proxy = new Ext.data.DirectProxy({
paramsAsHash: false,
api: {
read: doPci1102.readList,
update: doPci1102.updateList,
create: doPci1102.createList,
destroy: doPci1102.destroyList
}
});
var pci1102Ds = new Ext.data.DirectStore({
batch: true,
proxy: proxy,
reader: reader,
writer: writer,
autoLoad: false,
autoSave: false,
listeners: {
write : function(store, action, result, res, rs) {
alert(action);
},
exception : function(proxy, type, action, options, res, arg) {
alert(arg);
}
}
});
可以使用api中的read, 正碉读出三笔资料,可是当资料修改后,执行pci1102Ds.save(),用firebug看到的post是
{"action":"doPci1102","method":"updateList","data":["bas0001"],"type":"rpc","tid":5}
以上的"data":["bas0001"]是prg_no的值,如果把idProperty改成prg_name, 则是"data":["basname"],
data中没有包含所有6个栏位的资料...可是已设定了 writeAllFields: true
我试了以下的命令检查
pci1102Ds.doTransaction('update', pci1102Ds.getAt(0));
firebug中的post为 {"action":"doPci1102","method":"updateList","data":["bas0001"],"type":"rpc","tid":5}
pci1102Ds.doTransaction('create', pci1102Ds.getAt(0));
firebug中的post为 {"action":"doPci1102","method":"createList","data":[{"prg_no":"bas0001","prg_name":"basname","prg_spec":"test","upduser":"user","upddate":"981013","updtime":"22:30:54"}],"type":"rpc","tid":5}
请问有人知道是哪裹出问题吗?谢谢各位!
|
|