PDA

View Full Version : Not being able to map model in JsonStore using JsonReader



nuzahat sayyed
4 Oct 2011, 5:53 AM
Hi Guys.
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

carol.ext
4 Oct 2011, 1:59 PM
Is this a sencha touch issue too? Maybe someone can move the post if it is.

nuzahat sayyed
4 Oct 2011, 4:17 PM
Thanks for informing...
I have created new post in sencha touch Q&A
http://www.sencha.com/forum/showthread.php?149633-Not-being-able-to-map-model-in-JsonStore-using-JsonReader&p=656309#post656309