Setting values in multiselect combobox

2 posts, 0 answers
  1. Tomasz
    Tomasz avatar
    3 posts
    Member since:
    Nov 2015

    Posted 16 Nov 2015 Link to this post

    Hello.

    I have a multiselect combobox with checkeboxes. Let assume that variable "options" has value "Dog, cat". My combobox has items "dog", "cat", "pig". I want to by using JS select and check those two values. This code check Dog and cat, but only cat is really selected.

    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();
          }
        }
      }

  2. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 19 Nov 2015 Link to this post

    Hi Tomasz,

    I've already replied to your query in the following post. I suggest that we continue our conversation in the mentioned thread:
    http://www.telerik.com/forums/setting-values-in-multiselect-combobox

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top