Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q1 2012 released 04/11/2012
select

ComboBox / Multi-column ComboBox

select

select

  • RadComboBox provides support for multiple columns. Developers can now define any structure and it will be applied to all combobox items. The key benefit here is that this is achieved using templates.

    The second combobox features several items in one row by using the DropDownCssClass property (multipleRowsColumns class) and the following CSS rules:

            .multipleRowsColumns .rcbItem,
            .multipleRowsColumns .rcbHovered
            {
                float:left;
                margin:0 1px;
                min-height:13px;
                overflow:hidden;
                padding:2px 19px 2px 6px;
                width:125px;
            } 
        

    Multi-column mode supports all advanced AJAX features of the combo - load on demand, auto-complete, etc. Items loaded on demand are automatically formatted using the ItemTemplate as well.

    In addition, you can take advantage of the HeaderTemplate and FooterTemplate to improve the usability of the drop-down list.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.ComboboxExamplesCS.MultiColumnCombo.DefaultCS"
        Language="c#" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag runat="server" ID="Headtag1" />
        <link rel="stylesheet" href="styles.css" type="text/css" />
        <style type="text/css">
            .multipleRowsColumns .rcbItem, .multipleRowsColumns .rcbHovered
            {
                float: left;
                margin: 0 1px;
                min-height: 13px;
                overflow: hidden;
                padding: 2px 19px 2px 6px;
                width: 125px;
            }
            html.rfdButton a.rfdSkinnedButton
            {
                vertical-align: middle;
                margin: 0 0 0 5px;
            }
            label
            {
                display: inline-block;
                width: 200px;
                text-align: right;
                padding-right: 5px;
                margin-top: 10px;
            }
            * html.rfdButton a.rfdSkinnedButton,
            * html.rfdButton input.rfdDecorated
            {
                vertical-align: top;
            }
        </style>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <qsf:Header runat="server" ID="Header1" NavigationLanguage="C#" XhtmlCompliant="False" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Button1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Label1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadFormDecorator ID="FormDecorator1" runat="server" DecoratedControls="all" ControlsToSkip="Scrollbars"></telerik:RadFormDecorator>
        <!-- content start -->
    <asp:Label runat="server" ID="LabelSupervisor" AssociatedControlID="RadComboBox1"
    Text="Grid-like multi-column:" />

        <telerik:RadComboBox runat="server" ID="RadComboBox1" Height="190px"
            Width="420px" MarkFirstMatch="true" DataSourceID="SessionDataSource1" EnableLoadOnDemand="true"
            HighlightTemplatedItems="true" OnClientItemsRequested="UpdateItemCountField"
            OnDataBound="RadComboBox1_DataBound" OnItemDataBound="RadComboBox1_ItemDataBound"
            OnItemsRequested="RadComboBox1_ItemsRequested">
            <HeaderTemplate>
                <ul>
                    <li class="col1">Contact Name</li>
                    <li class="col2">City</li>
                    <li class="col3">Title</li>
                </ul>
            </HeaderTemplate>
            <ItemTemplate>
                <ul>
                    <li class="col1">
                        <%# DataBinder.Eval(Container.DataItem, "ContactName") %></li>
                    <li class="col2">
                        <%# DataBinder.Eval(Container.DataItem, "City") %></li>
                    <li class="col3">
                        <%# DataBinder.Eval(Container.DataItem, "ContactTitle") %></li>
                </ul>
            </ItemTemplate>
            <FooterTemplate>
                A total of
                <asp:Literal runat="server" ID="RadComboItemsCount" />
                items
            </FooterTemplate>
        </telerik:RadComboBox>
        <asp:Button runat="server" ID="Button1" Text="Select" OnClick="Button1_Click" />
        <br />
        <asp:Label runat="server" ID="Label2" AssociatedControlID="RadComboBox2" Text="Multiple rows and columns:" />
        <telerik:RadComboBox ID="RadComboBox2" runat="server" Height="190px"
            Width="420px" DropDownCssClass="multipleRowsColumns" DropDownWidth="460px">
        </telerik:RadComboBox>
        <asp:Label runat="server" ID="Label1" CssClass="selection-result" />
        <sds:SessionDataSource ID="SessionDataSource1" runat="server" PrimaryKeyFields="CustomerID"
            DisplayWarning="False" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ClearSessionOnInitialLoad="True" SelectCommand="SELECT * FROM [Customers]" SessionKey="System.Web.UI.Page_DataSource1">
        </sds:SessionDataSource>

        <script type="text/javascript">
            function UpdateItemCountField(sender, args) {
                //set the footer text
                sender.get_dropDownElement().lastChild.innerHTML = "A total of " + sender.get_items().get_count() + " items";
            }
        </script>

        <!-- content end -->
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451