Extjs商店不加载数据

时间:2013-08-22 12:54:38

标签: javascript extjs combobox store

你好我有绑定到组合框的商店。当我向组合框添加值时,它开始加载数据。响应中正确返回所有json数据,但不会加载任何记录进行存储。有什么建议吗?

我的商店看起来像:

    CheckersStore = Ext.extend(Ext.data.JsonStore, {
    constructor : function(cfg) {
        cfg = cfg || {};
        CheckersStore.superclass.constructor.call(this, Ext.apply({
            storeId : 'CheckersStore',
            api :{
                read : 'checker/getPagedList'
            },
            baseParams : {
                organizationId : 0
            },
            idProperty : 'userName',
            fields : [ {
                mapping : 'userName',
                name : 'value'
            }, {
                mapping : 'fullName',
                name : 'label'
            }, {
                name : 'organizationId',
                type : 'int'
            } ]
        }, cfg));
    }
});
new CheckersStore();

返回的JSON数据如下:

{
"start" : 0,
"limit" : 20,
"total" : 48,
"data" : [{
        "userName" : "KUUJOMAR",
        "fullName" : "Kuujo, Marketta Päivi",
        "organizationId" : 108
    }, {
        "userName" : "KUUKKKAL",
        "fullName" : "Kuukka, Kalle",
        "organizationId" : 108
    }
],
"organizationId" : 108

}

即使我只是尝试使用相同的参数调用store.load(),也会出现同样的问题。

1 个答案:

答案 0 :(得分:1)

尝试删除字段中的mapping属性。然后在商店root: 'data'内添加reader

reader: {
    root: 'data',
    type: 'json'
}

和字段:

fields : [{
    name : 'value'
}, {
    name : 'label'
}, {
    name : 'organizationId',
    type : 'int'
}]
相关问题