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

RadComboBox w/Checkboxes & ItemTemplate

2 Answers 309 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Shane
Top achievements
Rank 1
Shane asked on 20 Jul 2011, 06:38 AM
For our solution, we need to present a number of dynamic dropdowns with descriptive text choices but show only the simple Id key when the choice has been made.  To achieve this today I have provided a simple example code snippet from a test.aspx file showing the basics of how we are achieving this.
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
<%
    System.Collections.Generic.List<RadComboBoxItem> choices = new System.Collections.Generic.List<RadComboBoxItem>();
    for(int i=1; i <= 10; i++)
    {   choices.Add(new RadComboBoxItem("" + i + "- Complex Display Detail", "" + i));
    }
    RadComboBox1.DataSource = choices;
    RadComboBox1.DataBind();
%>
<telerik:RadComboBox ID="RadComboBox1" runat="server" AllowCustomText="true"
        DataTextField="Value" DataValueField="Value" Width="333px" CheckBoxes="false">
    <ItemTemplate>
        <asp:Label runat="server"><%# Eval("Text") %></asp:Label>
    </ItemTemplate>
</telerik:RadComboBox>
So if someone picks the "5 - Complex Display Detail" it will fill in the RadComboBox with 5.  For me, that is straight forward and functions as expected. 

The problem comes in if we want to now use the CheckBoxes="true" feature added to the latest release.  In this case it will not render properly due to the ItemTemplate.  So I have one of two choices:
  1. Figure out a way to have the checkboxes render as part of my customized template with similar results showing complex choices but simple display on selection.
  2. I need an alternate way to show Complex choices but have the actual choice showing on the RadComboBox as the code and not the complex choice description.

A good real world example would be to list the states by name but when you pick the state only have the 2 letter abbreviation show for the text to be submitted on the request (ie. pick Minnesota from the list of choices but have MN appear as the text for the RadComboBox request text).

Thanks,
Shane

2 Answers, 1 is accepted

Sort by
0
Accepted
Thad
Top achievements
Rank 2
answered on 20 Jul 2011, 12:37 PM
Hi Shane,

Unfortunately, it does not appear that this scenario is supported when using the built-in checkboxes property, although they are considering adding this feature in a future release.

http://www.telerik.com/community/forums/aspnet-ajax/combobox/setting-text-via-javascript-when-checkboxes-true.aspx

As of now, if you want to have checkboxes as well as custom text you'll need to implement your first option.  Fortunately, this has already been done and there are several examples in the Code Library section of Telerik's site.

Good luck!
Thad
0
Shane
Top achievements
Rank 1
answered on 21 Jul 2011, 03:24 PM
I opted to have it use the complex descriptor w/template when only single items selection and when checkboxes activated, simply show the value for both for now.  Thanks for the response.
Shane
Tags
ComboBox
Asked by
Shane
Top achievements
Rank 1
Answers by
Thad
Top achievements
Rank 2
Shane
Top achievements
Rank 1
Share this question
or