Work with ComboBox

Setting/getting value(s)

In order to select options in ComboBox, use the setValue() method. It takes one parameter:

  • ids - (string|number|array) the ids of items from data collection that should be selected in ComboBox
// select one option
// selects several options at once

Related sample:  Combobox. Set Value

To get the list of selected options, apply the getValue() method. It returns ids of selected options either as string(s) (by default) or as an array of strings. In the latter case you need to pass the following parameter:

  • asArray - (boolean) true, to return ids as an array of strings
var id = combo.getValue();
// -> "u1556098582074"
// returns ids of selected options as strings
var ids = combo.getValue();
// -> "u1556097609214,u1556097609228,u1556097609244"
// returns ids of selected options as an array of strings
var array_ids = combo.getValue(true);
// -> ["u1556097609214", "u1556097609228", "u1556097609244"]

Related sample:  Combobox. Get Value

Disabling/enabling ComboBox

To disable/enable ComboBox, make use of the disable()/enable() methods:

// disabling a combo box
// enabling a combo box

Related sample:  Combobox. Enable And Disable

Checking if a combobox is disabled

To check if a combobox is disabled, call the isDisabled() method:

combo.isDisabled(); // -> true/false

Related sample:  Combobox. Enable And Disable

Repainting ComboBox

You can repaint ComboBox on a page, e.g. after changing its configuration, using the paint() method:

// disabling ComboBox via the configuration object
combo.config.disabled = true;
// repaints ComboBox with a new config

Clearing input

It is possible to clear the ComboBox input from the selected value(s) with the help of the clear() method:


Related sample:  Combobox. Clear

Setting focus

When needed, you can set focus in the ComboBox input without opening the list of options. Use the focus() method for this purpose:


Related sample:  Combobox. Focus

Hiding/showing the popup

You can manipulate the visibility of the Combo popup with the help of the Popup API.

To hide/show the popup, use the corresponding methods:

// showing a popup;
// hiding a popup

Related sample:  Combobox. Popup

To control the process of showing/hiding the popup, apply the related events:"BeforeShow", function(HTMLElement){
    console.log("A popup will be shown");
    return true;                
});"AfterShow", function(HTMLElement){
    console.log("A popup is shown");                
});"BeforeHide", function(fromOuterClick,e){
    console.log("A popup will be hidden");
    return true;                
});"AfterHide", function(e){
    console.log("A popup is hidden");           

Related sample:  Combobox. Popup Events

Using Data Collection API

You can manipulate ComboBox options with the help of the Data collection API.

Adding options into ComboBox

It is possible to add more options into the initialized ComboBox on the fly. Use the add() method of Data Collection. It takes two parameters:

For instance:{value:"Russia"},1);

Related sample:  Combobox. Add/Remove

Updating ComboBox options

You can change config options of the option via the update() method of Data Collection. It takes two parameters:

For example, you can change the image of an option:"option_id",{
    value:"Russia", src: "../common/flags/ru.png"

Related sample:  Combobox. Update

Removing options from ComboBox

To remove an option, make use of the remove() method of Data Collection. Pass the id of the option that should be removed to the method:"option_id");

Check the full list of Data collection API

Back to top