PDA

View Full Version : Data not loading to Combobox from JSON



paritalak
12 Aug 2013, 11:47 AM
I am trying to load data to my combobox using AJAX call. I am able to get the data from server and my JSON object is coming.
My Combo box code is like this (inside container)
xtype: 'combobox',
displayField: 'displayValue',
valueField: 'returnValue',
store: new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy(new Ext.data.Connection({
url: 'myurl'
})),
root: 'competitor',
fields: ['displayValue','returnValue']
})
My JSON data is coming as like this
{"competitor":[{"displayValue":"BofA","returnValue":"BofA"},{"displayValue":"Citi","returnValue":"Citi"},{"displayValue":"Other","returnValue":"Other"},{"displayValue":"Wells","returnValue":"Wells"}]}


Issue is when I click on the combobox it is keep showing me as Loading.
I did check using Firebug, after I get the JSON object from server also not showing the data. Keep showing me as loading forever.I been fighting with this from past 2 days. Any help on this is greatly appreciated.

Mthor
12 Aug 2013, 11:52 AM
maybe set the queryMode:'remote' // or 'local' on the combobox

paritalak
12 Aug 2013, 11:56 AM
Tried both of them no luck.

Mthor
12 Aug 2013, 1:43 PM
you need a model for the store

paritalak
12 Aug 2013, 5:24 PM
I tried with defining the model. Is same as defining the fields.
I put the fields for you guys can understand what I am trying to do.

Appreciate any hints.

Thank
paritalak

julio.batista
13 Aug 2013, 3:09 AM
Are you sure that this is an Ext problem? Maybe your server code is in an infinite loop.

paritalak
13 Aug 2013, 4:57 AM
I did check the AJAX response and able to see the data in FIREBUG.
I am using Spring MVC to get the backend data. But not loading into the combobox.


If possible, Can someone please post the code to load data to combobox from Spring MVC if it is working. I am using FieldSet as the container.

Nontyper
15 Oct 2014, 10:18 AM
I am a little late to this issue, but I will post a fix in case someone is ever looking for it.

The problem is your root is not set correctly in your store.. configue like this.



store: new Ext.data.JsonStore ({
proxy: new Ext.data.HttpProxy(new Ext.data.Connection({
url: 'myurl',
reader: {
type: 'json',
rootProperty: 'competitor'
}
})),
fields: ['displayValue','returnValue']
})