Multi column Combo Box

2 posts, 0 answers
  1. Rahul
    Rahul avatar
    14 posts
    Member since:
    Feb 2013

    Posted 04 Jul 2013 Link to this post

    Hello

    I have created Multicolumn RAD Combo box and it is working fine but once user select any value it is displaying single column, is it possible to show multipal values as a text after user selects specific option. please find attached images, when it is displaying the list at that time it is showing the multipal columns in this example it is showing Template group,Effective Date,Expiry Date but once user select specific value then it is just showing Single column Template group. how to display multipal columns for selected value.


  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 05 Jul 2013 Link to this post

    Hello,

    Please try with below code snippet.



    protected void RadComboBox1_DataBound(object sender, EventArgs e)
    {
        //set the initial footer label
        ((Literal)RadComboBox1.Footer.FindControl("RadComboItemsCount")).Text = Convert.ToString(RadComboBox1.Items.Count);
    }
     
    protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
     
        DataTable dt = new DataTable();
     
        dt.Columns.Add("ID", typeof(int));
        dt.Columns.Add("ContactName", typeof(string));
        dt.Columns.Add("City", typeof(string));
        dt.Columns.Add("ContactTitle", typeof(string));
     
        dt.Rows.Add(1, "name1", "city", "title");
        dt.Rows.Add(2, "name2", "city", "title");
        dt.Rows.Add(3, "name3", "city", "title");
        dt.Rows.Add(4, "name4", "city", "title");
        dt.Rows.Add(5, "name5", "city", "title");
     
     
     
        RadComboBox1.DataSource = dt;
        RadComboBox1.DataBind();
    }
     
    protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
    {
        //set the Text and Value property of every item
        //here you can set any other properties like Enabled, ToolTip, Visible, etc.
        e.Item.Text = ((DataRowView)e.Item.DataItem)["ContactName"].ToString() + " "
            + ((DataRowView)e.Item.DataItem)["City"].ToString() + " "
            + ((DataRowView)e.Item.DataItem)["ContactTitle"].ToString();
        e.Item.Value = ((DataRowView)e.Item.DataItem)["ID"].ToString();
    }


    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
           <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>
       </telerik:RadScriptBlock>

    <telerik:RadComboBox runat="server" ID="RadComboBox1" Height="190px" Width="420px"
        MarkFirstMatch="true" EnableLoadOnDemand="true" HighlightTemplatedItems="true"
        OnClientItemsRequested="UpdateItemCountField" OnDataBound="RadComboBox1_DataBound"
        OnItemDataBound="RadComboBox1_ItemDataBound" OnItemsRequested="RadComboBox1_ItemsRequested"
        Label="Grid-like multi-column:">
        <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>


    Thanks,
    Jayesh Goyani
Back to Top