Adding Categories In RadListBox

2 posts, 0 answers
  1. Muhammad
    Muhammad avatar
    87 posts
    Member since:
    Oct 2012

    Posted 29 Dec 2010 Link to this post

    Hi,

    I want to add items in a specific category to my RadListBox Control. But I don't know how it would be done. I would like to give an example that how my RadListBox should appears. Fruits and Vegetables are categories and the items appear in each category should appear in a sorted manner in each category. Any help regarding this really appreciated.

    Fruits
    Apple
    Grapes
    Orange
    Vegetables
    Cucumber
    Okra
    spinach

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Dec 2010 Link to this post

    Hello Muhammad,

    As far as I know, RadListBox does not support "Separator". But the same behaviour can be achieved by using CSS and javascript code. The following CSS is used to set the style for ListItem.

    CSS:
    .categories
           {
               font-weight: bold;
           }

    And in order to disable selection, use the javascript code:
    JavaScript:
    function OnClientSelectedIndexChanging(sender, args) {
               if ((args.get_item().get_text() == "Fruits") ||(args.get_item().get_text() == "Vegetables"))
                   args.set_cancel(true);
               }

    And corresponding ASPX will be :
    ASPX
    <telerik:RadListBox ID="RadListBox1" runat="server" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging">
                <Items>
                    <telerik:RadListBoxItem Text="Fruits" CssClass="categories" />
                    <telerik:RadListBoxItem Text="Apple" />
                    <telerik:RadListBoxItem Text="Vegetables" CssClass="categories" />
                    <telerik:RadListBoxItem Text="Cucumber" />
                    <telerik:RadListBoxItem Text="Okra" />
                </Items>
    </telerik:RadListBox>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top