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

RadCombo Multi Selection Problem

1 Answer 42 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 27 Dec 2012, 11:32 AM
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.

1 Answer, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 28 Dec 2012, 12:14 PM
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.
Tags
ComboBox
Asked by
Ram
Top achievements
Rank 1
Answers by
Helen
Telerik team
Share this question
or