how to get all the sub menu items of a selected menu item till the irrespective of level?

3 posts, 0 answers
  1. kk luwang
    kk luwang avatar
    7 posts
    Member since:
    Mar 2010

    Posted 29 Apr 2010 Link to this post


    I've a requirement to get all the submenu items of a selected menu item till the deepest level whichever is available for that selected menu items. I mean is there any way to get all child sub-menu items and the grandchildren sub-menu items and so on for the selected menu item or is there any way to know the maximum/deepest level of a selected menuitem. As far as i've come across we can only go down the immediate next level of selected menu item. My requirement is to get and store DataFieldID of the selected menu item and all its available child menu items irrespective of the levels it has. Could you please provide me some sample code on this?

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

    Posted 30 Apr 2010 Link to this post


    I used a recursive function to get all the subitems of the clicked menuitem. I used a Dictionary structure in order to save the menuitems which stores the text and index of the sub menuitems.

        Dictionary<stringint> d = new Dictionary<stringint>(); 
        protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e) 
            RadMenuItem item = (RadMenuItem)e.Item; 
        public void getItems(RadMenuItem parentItem) 
            foreach(RadMenuItem item in  parentItem.Items) 
                d.Add(item.Text, item.Index); 
                if (item.Items.Count > 0) 

  3. Veronica
    Veronica avatar
    1213 posts

    Posted 05 May 2010 Link to this post

    Hi luwang,

    At this moment there is no function to get directly all the child Items for a particular RadMenuItem.

    That's why Princy is right! The solution is to use a recursive function. I created a sample project to show you how to do this. It is similar to the code of Princy but I use a List instead of a Dictionary. You may use the solution which you like most.

    Find the project in the attached .zip file.

    Hope this helps.

    Kind regards,
    Veronica Milcheva
    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.
Back to Top