Reputation: 4281
I create a combobox with these are the configuration I given.
displayField: 'TEXT',
valueField: 'ID',
Here is my store
this.store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'combodata.json',
actionMethods: {
read: 'GET'
},
reader: new Ext.data.JsonReader({
rootProperty: 'ROOT.TAG'
})
}),
fields: [
{name: 'ID', mapping: 'ID', type: 'string'},
{name: 'TEXT', mapping: 'TEXT', type: 'string'}
],
autoLoad: true
});
And here is my JSON
{
"ROOT": {
"TAG": [{
"ID": 01,
"TEXT": "ABC"
},
{
"ID": 02,
"TEXT": "DEF"
},
{
"ID": 03,
"TEXT": "GHI"
}]
}
}
I can see URL is going into response and but data is not loading in combobox. Even data is not going to store itself. Can anyone help me why data is not loading in combo. Update :
this.store = new Ext.data.Store({
autoLoad: true,
fields: [
{name: 'ID', mapping: 'ID', type: 'string'},
{name: 'TEXT', mapping: 'TEXT', type: 'string'}
],
proxy: new Ext.data.HttpProxy({
url: 'adata.json',//this.url,
headers: {
'Accept': 'application/json; charset=utf-8'
},
actionMethods: {
read: 'GET'
},
reader: new Ext.data.JsonReader({
root: 'ROOT'
})
})
});
Upvotes: 1
Views: 58
Reputation: 2783
I made this fiddle, I'm loading the combo from a JSON file.
Notice that inside the Assets
folder has the JSON file data.json
that is loaded by the store.
As the Lorenz commented, it is necessary to make some changes, take a look, I hope I can help you!
Upvotes: 1
Reputation: 19915
You tags indicate that you use ExtJs 3.4. rootProperty
was not available in that version. Use root
instead.
Also, I don't think that ExtJs 3.4 already allowed to specify a nested root like root: 'ROOT.TAG'
, probably this is not possible an you have either to change the format of the JSON returned or upgrade to a newer version of ExtJs.
Try using this format with root: 'ROOT'
:
{
"ROOT": [{
"ID": 01,
"TEXT": "ABC"
},
{
"ID": 02,
"TEXT": "DEF"
},
{
"ID": 03,
"TEXT": "GHI"
}]
}
Upvotes: 0