RadCombo Multi Selection Problem

2 posts, 0 answers
  1. Ram
    Ram avatar
    49 posts
    Member since:
    Feb 2009

    Posted 27 Dec 2012 Link to this post

    Hi,
    I am using following script for multi selection in radcombo
    <telerik:RadComboBox ID="RadComboBox1" runat="server" EmptyMessage="Select Countries"
                  AllowCustomText="true" MarkFirstMatch="true" HighlightTemplatedItems="true" Width="150px"
                  OnClientDropDownClosed="onDropDownClosing">
                  <ItemTemplate>
                      <div onclick="StopPropagation(event)" class="combo-item-template">
                    <asp:CheckBox runat="server" ID="chk1" Text='<%# Eval("Country") %>' onclick="onToCheckBoxClick(this,'')"/>
                          
                      </div>
                  </ItemTemplate>
              </telerik:RadComboBox>
    and javascript is as follows:
    function onToCheckBoxClick(chk, temp) {
                
                var show = document.getElementById(temp);
                var combo = $find("<%= RadComboBox1.ClientID %>");
                
                cancelDropDownClosing = true;
                var text = "";
                var values = "";
                var items = combo.get_items();
                for (var i = 0; i < items.get_count(); i++) {
                    var item = items.getItem(i);
                    var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
                    if (chk1.checked) {
                        text += item.get_text() + ";";
                        values += item.get_value() + ";";
                    }
                }
     
                text = removeLastComma(text);
                values = removeLastComma(values);
     
              
            }
     
            var cancelDropDownClosing = false;
     
            function StopPropagation(e) {
                e.cancelBubble = true;
                if (e.stopPropagation) {
                    e.stopPropagation();
                }
            }
     
            function onDropDownClosing() {
                cancelDropDownClosing = false;
            }
            function removeLastComma(str) {
                return str.replace(/;$/, "");
            }

    From above code I am able to select multiple values but the selected values are not appearing drop down as a semicolon separated string.
    what I am missing in the code can any one help?

    Thanks,
    Ram.
  2. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 28 Dec 2012 Link to this post

    Hello Ram,

    Probably you will find helpful the following code library project:

    http://www.telerik.com/community/code-library/aspnet-ajax/combobox/radcombobox-advanced-multiple-selection.aspx

    Also RadComboBox has built-in checkboxes support from Q2 2011.

    Greetings,
    Helen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top