PDA

View Full Version : combo not showing JSON data



rohan.chandane
2 Sep 2010, 5:08 AM
JSON Object coming from web service:


{"my_json":[["value1"],["value2"],["value3"]]}

Store which loading this JSON:


var myStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: "some inDomainURL"
})
,reader: new Ext.data.JsonReader({ root: 'my_json',id:'my_json'}, [{myValue:'my_json'}])
,remoteSort: false
});
myStore.load();

Combo box which is using this myStore:


xtype:'combo'
,hideLabel : true
,id: 'my-combo'
,width: 120
,emptyText: 'Select OS..'
,store: osStore
,displayField: 'myValue'
,valueField: 'myValue'
,mode:'remote'
,triggerAction: 'all'
,typeAhead: true
,forceSelection: true
,allowBlank:false

I am getting data from server in JSON, combo loads data, however value is not displayed. am I missing something in JSON reader?

Animal
2 Sep 2010, 7:15 AM
That's an Array you are receiving. You need an ArrayReader

Condor
2 Sep 2010, 7:26 AM
Also, your JsonReader has an invalid fields config.

Try:

reader: new Ext.data.ArrayReader({
root: 'my_json',
idIndex: 0
}, [
{name: 'myValue'}
])