PDA

View Full Version : displaying Nested Model in two different combobox



vivekiris
8 May 2013, 10:48 AM
I have one store that generate nested data I want to call server only once to load this data

{"data":[{"firstCombo":"A","data1":[{"seccondCombo":"B,C"}],"data2":[{"thirrdCombo":"D,E"}]}]}

so what should be the model and view code so that I can populate three comboboxes without calling server again and again I am able to populate first combobox using a store that have root : data

slemmon
13 May 2013, 7:32 AM
Are you using an Ext.Ajax.request() to pull the data down?
If so, once you have the data you can Ext.decode() the response. Then in a callback you can do something like:


combo1.getStore().loadData(resp.data.firstCombo);
combo2.getStore().loadData(resp.data.data1.secondCombo);
... etc.

vivekiris
13 May 2013, 8:20 AM
Thanks for your reply ,
yes I am using Ajax request , but I am using extjs 4 I have a Store
proxy: {
type: 'ajax',
url: abc.do',
reader: {
type: 'json',
root: 'data'
}
}

and define model with hasMany relation of different model.

and below is my view that uses store

{
xtype: 'combobox',
fieldLabel: 'Name',
store: 'myStore,
displayField: 'firstCombo',
valueField: 'firstCombo'
},



{
xtype: 'combobox',
fieldLabel: 'Type',
store: ,
displayField: ,
valueField: '
},
here I am able to display data in first combo
so please let me know what should I give in the second combo in store, displaytype and value filed to display data




Are you using an Ext.Ajax.request() to pull the data down?
If so, once you have the data you can Ext.decode() the response. Then in a callback you can do something like:


combo1.getStore().loadData(resp.data.firstCombo);
combo2.getStore().loadData(resp.data.data1.secondCombo);
... etc.

slemmon
20 May 2013, 8:37 AM
You mentioned using a hasMany - does each record for ComboA have a series of records you'll be loading to ComboB when a record is selected in ComboA or the list for ComboB is static - not dependent on a selection from ComboA?

vivekiris
20 May 2013, 9:47 AM
Yes, they are dependent on ComboA, mean for single Value of ComboA there would be a list of values for Combp B & C