This is a migrated thread and some comments may be shown as answers.

Setting values in multiselect combobox

1 Answer 71 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tomasz
Top achievements
Rank 1
Tomasz asked on 16 Nov 2015, 05:27 PM

Hello.

I have multi selection combobox with checkboxes. Variable "options" has value: "Cat, Dog". Combobox has values: "Cat", "Dog", "Pig".  I want to check and select few values by using java script. I am not able to select few values at ones. This code only select "Dog".

function setValuesInCombobox(options) {
   var controler =$find(getClientIdById(cboBuildingControlName));   
   controler.set_value(options);
   controler.set_text(options);
   var allChoicesFromCbo = controler.get_items()._array; 
   var selectedOptions =  options.split(",");
 
   for(i = 0; i < selectedOptions.length; i++) {
     var building = selectedOptions[i].trim();
     for(j = 0; j < allChoicesFromCbo.length; j++) {       
       var nameOfBuildingInCbo = allChoicesFromCbo[j]._properties._data.value;
       if( nameOfBuildingInCbo == building) {
         allChoicesFromCbo[j]._setChecked(true);
         allChoicesFromCbo[j].select();
       }
     }
   }
 }

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 19 Nov 2015, 07:52 AM
Hello Tomasz,

I've created a sample web site to demonstrate how you can achieve this requirement. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Tomasz
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or