+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / show categories with sub categories

show categories with sub categories

4 posts, 0 answered
  1. Asif
    Asif avatar
    110 posts
    Registered:
    18 Nov 2010
    17 Dec 2010
    Link to this post
    Hi,
    I want to show the categories with their sub categories and sub to sub categories and so on in the drop down box. How can I do that?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Dec 2010
    Link to this post
    Hi Asif,

    Wrap RadTreeView control in a RadComboBox

    var contentManager = newContentManager();
    allCategories = contentManager.GetCategories(0, 0, "CategoryName ASC");
    this.CategoriesTreeView.DataTextField = "CategoryName";
    this.CategoriesTreeView.DataFieldID = "ID";
    this.CategoriesTreeView.DataValueField = "ID";
    this.CategoriesTreeView.DataFieldParentID = "ParentCategoryID";
    this.CategoriesTreeView.DataSource = allCategories;
    this.CategoriesTreeView.NodeDataBound +=newTelerik.Web.UI.RadTreeViewEventHandler(CategoriesTreeView_NodeDataBound);
    this.CategoriesTreeView.DataBind();
      
     voidCategoriesTreeView_NodeDataBound(objectsender, Telerik.Web.UI.RadTreeNodeEventArgs e)
        {
            ICategory nodeCategory = (ICategory)e.Node.DataItem;
            e.Node.NavigateUrl = "";
            e.Node.ToolTip = nodeCategory.CategoryName;
              
        }

    You have to use RadComboBox template.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Asif
    Asif avatar
    110 posts
    Registered:
    18 Nov 2010
    17 Dec 2010
    Link to this post
    Hi Ivan
    Thanks for your help. I am almost there. Now there are 3 things I have to achieve.
    1. Please find the screen shot. I have to remove the expand and collapse and the doted line and make it similar to the default catefgory combobox.
    2. I am using a javascript to make the category visible on item select but when I click on search button the result is showing on the basis of selected item but the item gets disappear from the selected combo box. Please find the attached image for reference.
    3. I want to add an item which should be similar to the default selectbox "*UnCategorized*".
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Dec 2010
    Link to this post
    Hello Asif,

    1. You can remove the embedded styles of the control or override them in a custom stylesheet.

    2. It looks like the code you use does not keep the controls state. You can save the selected item in a cookie  before making a search and read it after that.

    3. You can add a new item programmatically by using the client side or server side API of the RadComboBox control.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered