RadComboBox w/Checkboxes & ItemTemplate

3 posts, 1 answers
  1. Shane
    Shane avatar
    18 posts
    Member since:
    Jan 2011

    Posted 20 Jul 2011 Link to this post

    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. Answer
    Thad
    Thad avatar
    106 posts
    Member since:
    Sep 2010

    Posted 20 Jul 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shane
    Shane avatar
    18 posts
    Member since:
    Jan 2011

    Posted 21 Jul 2011 Link to this post

    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
Back to Top