Extjs JsonStore data 赋值问题,在线等

yangf2008 发布于 2011/06/21 11:02
阅读 3K+
收藏 0

var myData = new Ext.data.Store({
    autoLoad:true,
    baseParams :{
        cmd: 'project',
        action: 'searchMumbers',
        start: 0,
        limit: 5
    },
    proxy: new Ext.data.HttpProxy({
        url:URL
    }),
    reader: new Ext.data.JsonReader({
        root:'record',
        id: 'id',
        totalProperty: 'totalRecords',
        idProperty:'id',
        fields:fields
    })
});

myData.on('load',function(tempstore){alert(Ext.util.JSON.encode(myData.getAt(0).data));});可以弹出数据  {"mumbername":"mumber1","mumberdept":"0001"}

后台返回的数据:

头信息Post响应JSON
{'result':'success', 'totalRecords': 11,record:[{"mumbername":"mumber1","mumberdept":"0001","mumberid":1},{"mumbername":"mumber2","mumberdept":"0002","mumberid":2},{"mumbername":"mumber3","mumberdept":"0003","mumberid":3},{"mumbername":"mumber4","mumberdept":"0004","mumberid":4},{"mumbername":"mumber5","mumberdept":"0005","mumberid":5}]}


var firstGridStore = new Ext.data.JsonStore({
    fields : fields,
    data   : myData,
    root   : 'record'
});

但是在data 赋值的时候出错,向大家请教,谢谢

加载中
0
y
yangf2008

没有人回答吗?

0
被爱
被爱

var myData = [{'result':'success', 'totalRecords': 11,record:[{"mumbername":"mumber1","mumberdept":"0001","mumberid":1}]];

var firstGridStore = new Ext.data.JsonStore({
    fields : ['
mumbername','mumberdept',{'mumberid',type:int}],

    data   : myData,
    root   : 'record'
});

fields得设置读取的字段 

返回顶部
顶部