I am facing a problem in sencha while mapping Ext.data.JsonStore model using Ext.data.JsonReader.
Json response from server (server model):
{"rows":[{"id":1,"firstname":"Bill"},{"id": 2,"firstname":"Ben"}]}
Model used in Json Store:
Ext.regModel( 'mycabinet', {
fields: [
{ name : 'DeviceId', type: 'int' },
'CabinetName']
});
json Reader code:
var iccDeviceReader = new Ext.data.JsonReader({
// metadata configuration options:
idProperty: 'id',
root: 'rows',
fields: [
{name: 'CabinetName', mapping: 'firstname'},
{name:'DeviceId',mapping:'id'}
]
});
json store code:
app.iccDS = new Ext.data.JsonStore( {
model : 'mycabinet',
sorters : 'CabinetName',
getGroupString : function(record) { return record.get('CabinetName')[0]; },
proxy : {
type: 'ajax',
url : '/icc/js/data.js',
reader:iccDeviceReader
},
autoLoad: true
} );
I am expecting that "mycabinet" model will get populated with "server model". However, mapping doesnt occur. I even tried using convert without any success(name:'DeviceId',mapping:'id',convert: function(v){return v.id;})
Any help will be highly appreciated. Thanks