Dynamically change the combobox list in a form


#1

Hi

I’ve got a form which includes two comboboxes. The contents of the second combobox depend on the selection a user makes in the first combobox. I’m able to retrieve the data from the first combobox and create a new array which should be used for the second combobox.

When I’m using just two comboboxes (NO FORM), I’m able to do myComboBox.data.parse(newArray). And that works just fine. But in a form that syntax won’t work. Neither does myForm.getItem(‘myCombo’).data.parse. I also can’t use the SetProperties on the attribute data.

Is there a way I can populate the entire combobox on the fly?

Thanks
Kevin


#2

Please, try to use:

var myComboBox= form.getItem("myCombo").getWidget();
myComboBox.data.parse(newArray)

It is mentioned here:
https://docs.dhtmlx.com/suite/form__combo.html#workingwithcombo
right at the bottom of the page. :sweat_smile: