职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 331|回复: 0

有人使用过JsonWriter做资料的更新吗?

[复制链接]
曾经的小孩 发表于 2011-8-22 11:31 | 显示全部楼层 |阅读模式

-

我使用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}
   
    请问有人知道是哪裹出问题吗?谢谢各位!
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-5-16 13:29 , Processed in 0.134912 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表