kuldarim
kuldarim

Reputation: 1106

Extjs store does not load data

Hello i have store which is binded to combo box. And when i add value to combo box it starts loading data. All json data is correctly returned in response, but no records are loaded to store. Any suggestions?

My store looks like :

    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();

returned JSON data looks like :

{
"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

}

and even if i just try to call store.load() with same parameters, same problem also appears.

Upvotes: 1

Views: 4351

Answers (1)

Jeff Shaver
Jeff Shaver

Reputation: 3355

Try getting rid of the mapping property inside the fields. Then add root: 'data' inside the stores reader.

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

and the fields:

fields : [{
    name : 'value'
}, {
    name : 'label'
}, {
    name : 'organizationId',
    type : 'int'
}]

Upvotes: 2

Related Questions