View Full Version : Combobox data not showing after store updates

5 Aug 2014, 5:16 AM
i am trying to use array as a combo store, it works for hardcoded arry which is commented but when i try to load countryList form server through AJAX ..the array gets the data but its nor showing in comboBox

initComponent: function() {
//countryList : ['Red', 'Yellow', 'Green', 'Brown', 'Blue', 'Pink', 'Black'],
success: function(response, options){
var jsonResp = response.responseText;
jsonResp =jsonResp.split("[").join("");
jsonResp =jsonResp.split("]").join("");
countryList = jsonResp.split(",");
countryList.push("From Server");
Ext.Msg.alert("Info","this.CountryList from Server : "+countryList);
// var countryCom = Ext.getCmp()'countryCombo');
//countryCom.store = countryList;

scope : this,


items : [{ xtype : 'combo',
//store: ["India","Bhutan","Nepal"],
store: countryList

5 Aug 2014, 8:09 AM
Why are you using a direct call to Ext.Ajax.request rather than loading the data through the store?

Why are you using crazy custom JSON parsing rather than a standard parser?

An AJAX request will be asynchronous, it doesn't pause initComponent to wait for it to complete.

Configuring a combobox using an array is a shorthand to create a store with some default options. You should read up about stores, make sure you understand them.


For more about configuring combobox stores:


6 Aug 2014, 10:30 PM
To deduce use of store and model for simple array data with no key value paring even i am not going to reuse the store so

7 Aug 2014, 12:42 AM
I don't really understand what you're saying but if you want to pass an array as a store config you'll have to wait until you have the data before creating the combobox. Once you've created the combobox it will have a store, whether you 'need' one or not. If you want to load data after that you'll need to do it via the store. It doesn't have to be loaded remotely, you can add data to the store yourself if you wish.

From everything I've seen you would be better off using a store and loading the data via a proxy in the usual manner. If you need to handle a flat array of data you should customize the reader accordingly.