这个是js代码,获取的是json数据,使用了reader
this.store=new Ext.data.Store({ idProperty: 'itemid', autoLoad:this.autoLoad, url:this.url, reader:new Ext.data.JsonReader({ fields:[{name:'id'},{name:"itemid"},{name:"itemname"},{name:'pycode'},{name:'wbcode'},{name:'gbcode'},{name:'parentcode'},{name:'issys'},{name:'numvalue'}] }) });这个是响应的json的数据
[{"id":16,"itemid":"1","itemname":"全自费","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"2","itemname":"新农合","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"3","itemname":"包干","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"4","itemname":"职工医保","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"5","itemname":"其他","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null}] 最终的结果
其错误的原因不多说了,说怎么解决这个问题:
将js]代码该为:
this.store=new Ext.data.JsonStore({ idProperty: 'itemid', autoLoad:this.autoLoad, url:this.url, fields:[{name:'id'},{name:"itemid"},{name:"itemname"},{name:'pycode'},{name:'wbcode'},{name:'gbcode'},{name:'parentcode'},{name:'issys'},{name:'numvalue'}] }); 需要注意的是上面的fields需要加上[{name:"属性"}]
然后这次的响应的数据
[{"id":16,"itemid":"1","itemname":"全自费","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"2","itemname":"新农合","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"3","itemname":"包干","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"4","itemname":"职工医保","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null},{"id":16,"itemid":"5","itemname":"其他","pycode":null,"wbcode":null,"gbcode":null,"parentcode":null,"issys":"2","numvalue":null}] 这次的结果:
注意:如果你的返回的是json数据的话,那么最好用jsonStore会比较好.
extjs版本:Ext JS Library 3.3.1