what is proper way to get list of checked items in javascript?

2 posts, 0 answers
  1. Doug
    Doug avatar
    104 posts
    Member since:
    Aug 2014

    Posted 16 May 2017 Link to this post

    I used javascript debugger and did find an object to get the "checked" items in my RadComboBox.
    what is the proper way to do this so I can clean up my code?
    in my case I am getting the list of categories to send to RadScheduler provider

        window.OnClientAppointmentsPopulating = function (sender, eventArgs) {
            var combobox = $find("<%=ddlCatToShow.clientID %>");
            var list = "";
            var items = combobox.get_items();
            var array = combobox._checkedIndices.toString().split(','
            for (var i = 0; i < array.length-1; i++) { 
          
                var item = items.getItem(array[i]);
            //alert(item.get_text()); 
            //alert(item.get_value());   
                list += item.get_value() + ",";
            
            eventArgs.get_schedulerInfo().CategoryList = list.replace(/,\s*$/, "");
    };


  2. Loïc
    Loïc avatar
    27 posts
    Member since:
    Oct 2016

    Posted 19 May 2017 in reply to Doug Link to this post

    Hi Doug,

    The best proper way to get list of checked items in javascript is to call the ".get_checkedItems()" method of your RadComboBox.

    var combobox = $find("<%=ddlCatToShow.clientID %>");
    var checkedItems = combobox.get_checkedItems();
     
    for (var i = 0; i < checkedItems.length; i++) {
      // Your code here
    }

     

    More information here : RadComboBox Object.

Back to Top