This might be a silly question, but I want to ask if there is a possibility to change another combobox’s store data when a combobox selected value is changed.
It might be confusing, so let me give a clear example,…
comboboxA has a datastore that contains of country’s name
comboboxB has a datastore that contains of city’s name
so, the data in comboboxA could be:
- USA - Mexico - England
And the data incomboboxB when the value of comboboxA is “USA” would be:
- Texas - New York - Washington
but when the value of comboboxA is “England”, the data in comboboxB would be:
- London - Manchester
How could I do that?
I’ve try:
comboboxA.on("change", function(cb, newValue, oldValue){
if(newValue == "USA"){
comboboxB.store.loadData(["Texas", "New York", "Washington"]);
comboboxB.setValue("Texas");
}
else if(newValue == "England"){
comboboxB.store.loadData(["London", "Manchester"]);
comboboxB.setValue("London");
}
});
Is there something wrong with my code?
See the updated Combobox FAQ. You must use the listeners for the select event. See the example in “linked comboBoxes”