PDA

View Full Version : ONE JSON STORE FOR MULTIPLE COMBOBOXS



AJAIN32
13 May 2014, 9:35 PM
Hi,

I have been trying to load some comboboxes with one Json file. I have creater a mock json object and i am loading the store with that data.
I am not able to populate data in the comboboxes.I am getting the data in the success call of the store.load method. for example i am getting one json file having two objects Combo1 and Combo2 having some key value pairs.

But how can i set the combo1 values in first dropdown and combo2 in the second dropdown.

Any help would be appreciable, please reply !!

Thanks,
Ankit

jsakalos
13 May 2014, 10:05 PM
You need to decode the response yourself and then call store.loadData() (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-loadData) on both combos' stores.

AJAIN32
13 May 2014, 10:23 PM
Thanks for reply,

can you please tell me that can i decode the records in the success call of the store load request and how can i do that as i am getting data inside the records[0].raw.combo1,records[0].raw.combo2 ??

jsakalos
13 May 2014, 11:00 PM
I would probably configure stores as local, then I'd send a manual request (Ext.Ajax.request) and in success callback of the request I'd loaded the stores from the decoded response. It means stores w/o proxies and readers.

AJAIN32
14 May 2014, 12:55 AM
Thanks for the prompt reply,
I have created 2 stores without proxies and reader and in one main store i am loading the Json data and i am loading data of combo1 in first store by using "Combo1.store.loadData(data)" this line got excecuted but when i am clicking on first combo I am getting one exception.

"Microsoft JScript runtime error: Ext.data.proxy.Server.buildUrl(): You are using a ServerProxy but have not supplied it with a url."

I tried to figure out but could not understand why url is required for the store which is not having proxy.

Please help !!

AJAIN32
14 May 2014, 1:15 AM
Hi,

I got the issue, in combobox i have changed QueryMode(queryMode: 'local') and now its working.

I want to know is it possible to associate same store with multiple comboboxes and then load the data in one call. Right now i am using a store which is having all the data of multiple comboboxes, and for each combo i have to create a local store and load the data in it.

Is there any approach better than this ??

Regards,
Ankit

jsakalos
14 May 2014, 3:43 AM
For something simple like "Gender:1-Male, 2-Female, 3-Unknown" the answer is yes, use one store. If you need to filter or sort the store for different combos differently then answer is no, you need separate stores. In other words, one store for multiple combos mean that combos will be identical.

AJAIN32
14 May 2014, 3:50 AM
yes, comboboxes which i want to fill are "Master data" that wont be changed frequently.

so if i use one store for all comboboxes and if in each combobox config i assign the same store then how can i populate data on each combo.
for now we have seprate store so its easy to load the data by store.loadData(data).

it will be same if we use same store for all ???

I hope i was able to clear out the issue.

Thanks !!

jsakalos
14 May 2014, 4:06 AM
No problem, just load that store. Combos are only visualization of the data in the store so all will populate once their store is loaded.

AJAIN32
14 May 2014, 4:08 AM
Thanks for all useful information !!!

I will definetly try that.