PDA

View Full Version : store auto load is not holding the data post rest response



vick_44
10 Dec 2016, 1:59 PM
I am not able to figure out what is the problem in my code, I am trying to fetch a json data from rest service which is not getting loading onto store.data object.

My form has below content:


xtype : 'combobox', fieldLabel : 'Project ID',
name : 'prjId',
itemId : 'prjId',
allowBlank : false,
store : 'ITracker.store.ProjectIdStore',
queryMode : 'local',
displayField : 'key',
valueField : 'key',
margin : '10 0 0 10'


My ProjectIdStore has below content:


Ext.define('ITracker.store.ProjectIdStore', { extend : 'Ext.data.Store',
model : 'ITracker.model.ProjectIdModel',
autoLoad : true
});




and my model has below content :


Ext.define('ITracker.model.ProjectIdModel', { extend : 'Ext.data.Model',
fields : [ {
name : 'key', type : 'int',
name : 'value', type : 'string'}
],
proxy: {
type: 'rest',
url: 'jsonData/getProjectIds',
reader: {
type: 'json',
rootProperty: 'data'
}
}


});


When i run my application, it is able to hit the rest service and is able to retrieve data which has below content


{"errMsg":"","data":[{"key":1,"value":"blah1"},{"key":2,"value":"blah2"},{"key":3,"value":"VOIP"}],"success":true}


55620

but the combobox is not loaded with the "key" list, and that is because when i check the getStore().data.items it is an empty list. Any idea what i am doing wrong. I tried moving the proxy to the store but that has the same behaviour as well.

any help or pointers is deeply appreciated.

vick_44
10 Dec 2016, 2:14 PM
sorry my bad,.. this is really embarrassing. Literally wasted one good hr on this. I have missed couple of braces in model.



fields : [ {
name : 'key', type : 'int' },
{name : 'value', type : 'string'}
],

Guess burning the midnight oil is mostly bad way to go about things.