PDA

View Full Version : chain combobox



Jensen
18 Mar 2010, 11:34 PM
Hi,
I have two Combobox when I choose something in the first combo in the second combo there store is reloaded with other data.



combo1 = new Ext.form.ComboBox({
hiddenName: 'ebayshop',
store: ebayshopnamestore,
valueField:'shopid',
displayField:'shopname',
fieldLabel: 'Ebayshop',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Shopname',
selectOnFocus:true,
forceSelection: true,
lazyInit: false,
allowBlank:false,
width: 250,
listeners:{
'select':function(combo, value){
shopname = value.get("shopname");
combo2.reset();
storecategories.proxy.conn.url = '/url/'+shopname.toLowerCase()+'/';
storecategories.load();

}
}
}),

combo2 = new Ext.form.ComboBox({
hiddenName: 'ebayshopcategory',
store: storecategories,
valueField:'i',
displayField:'n',
fieldLabel: 'Shop-Kategorie',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Shop-Kategorie',
selectOnFocus:true,
forceSelection: true,
lazyInit: false,
loadingText:'Hersteller werden geladen',
allowBlank:true,
}
}),
That works fine. But when I will change some data I can't populate the Comobox. The first loads fine. But the Second is not right loaded because it depends on the value of combo1.
So the combo2 is loaded with the wrong store an shows me the wrong data. I only can see the id in the Combo2 because the row to the id is not found in the Data from combo2.
How can I load the second Store (combo2) after I habe the value from the first Combo. Must be someting like an Event "afterload"
Thank you very much

Mfg Jens

steffenk
19 Mar 2010, 1:33 AM
i did that quite a long time ago, have a look:
http://www.sk-typo3.de/ExtJS-Dynamische-Comboboxen.337.0.html

Jensen
19 Mar 2010, 1:38 AM
Hey,
I knew your code. My is based on this? You tried to put this in a form, save the data and then to populate again? You will see that it is not populating your data right. The events select are not loaded and you will habe the wrong data in the combobox!

MFG Jensen

steffenk
19 Mar 2010, 1:41 AM
I don't understand. I used it as it is in a form with submit (normal html, i only used ExtJS for populating) and i didn't encountered any problems.

Jensen
19 Mar 2010, 1:50 AM
I don't understand. I used it as it is in a form with submit (normal html, i only used ExtJS for populating) and i didn't encountered any problems.

I cant't see that you load the store2 for the second combo on start. It just loads when you select combo1 but not when you populate / load the data?!

steffenk
19 Mar 2010, 1:56 AM
maybe you are too early. Load first store after all components are rendered.

Jensen
19 Mar 2010, 2:01 AM
My Forms show the data. Thats not the Problem. I need the right data in the combo. Is in you code the select event fired when you populate the form?! I don't think. Where else is the second store loaded?! I see it onyl in the select from the combo, not on populate!