Check documentation for the latest version of dhtmlxSuite Operating Combobox's Options DHTMLX Docs

Operating Combobox's Options

There's a set of operations you can apply to the Combo options. You can find the list of them below:

Adding Option to Combo

To add options to Combo, use the addOption method:

myCombo.addOption(options);

The method takes a list of options that should be added to Combo. The type of the options parameter may differ. Please, check the related samples.

Related sample:  Script - single option
Related sample:  Script - array of arrays
Related sample:  Script - array of objects

Deleting Option

To delete an option, use the deleteOption method:

myCombo.deleteOption(value);

The method takes the option's value as a parameter.

Updating Option

To update an option, use the updateOption method:

myCombo.updateOption(oldvalue,value,text,css);

The parameters are:

  • oldvalue - (string) the current option's value
  • value - (string) a new option's value
  • text - (string) a new option's text
  • css - (string) a new style for the option

Selecting Option

To select an option in the Combo, use the selectOption method:

myCombo.selectOption(ind);

It takes the index of the option in question as a parameter.

To unselect a selected option, use the unSelectOption method:

myCombo.unSelectOption();

Getting Value of Selected Option

To get the selected value option, use the getSelectedValue method:

myCombo.getSelectedValue();

It returns the value of the selected item as a string.

Getting Text of Selected Option

To get the text of the selected option, use the getSelectedText method:

myCombo.getSelectedText();

Getting Text of Combo Editor

To get the text set in Combo editor, use the getComboText method:

myCombo.getComboText();

To set text into the Combo editor, use the setComboText method:

myCombo.setComboText(text);

As a parameter, it takes a new text to be set into the Combo editor.

Back to top