RadMenu Add Child Menu Item to Parent Menu Item

2 posts, 0 answers
  1. Joe
    Joe avatar
    4 posts
    Member since:
    Apr 2014

    Posted 12 Aug 2015 Link to this post

    Hi

     I have been using the Client Side API and also looking all over the internets for a solution to this problem and have not seen a thing.

     I have a RadMenu that is created dynamically server side. This menu can have as many menu items as the user defines. I would like to add a child menu item to a parent menu item via Telerik's Client Side API. 

    The Add and Insert functions both seem to add the item to the menu as a parent instead of adding the child item inside of the parent menu item. Is there a way I can add the child item to the parent item, so that it displays within the parent items drop down? Ultimately, I would like to create a multilevel drop down.

     Here is some test code I have written, to see if this is possible.Thanks!

    <script> 

        function AddMenuItems() {
                var menu = $find("<%= testMenu.ClientID %>")
                menu.trackChanges();

                var parentItem = new Telerik.Web.UI.RadMenuItem();

                parentItem.set_text("More...");
                menu.get_items().add(parentItem);

                var childItem = new Telerik.Web.UI.RadMenuItem();
                childItem.set_text("child");
                menu.get_items().insert((menu.get_allItems().length), childItem); <== Adds the item after the parent item instead of inside. 
                menu.commitChanges();
            }

        </script>
        
        <AxnMenus:AxnMenu ID="testMenu" runat="server" OnClientLoad="AddMenuItems">
        <Items>
            <AxnMenus:AxnMenuItem Text="item 1" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 2" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 3" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 4" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 5" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 6" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 7" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 8" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 9" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 10" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 11" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 12" runat="server"/>
            <AxnMenus:AxnMenuItem Text="item 13" runat="server"/>
        </Items>
        </AxnMenus:AxnMenu>
        

    </asp:content>

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 13 Aug 2015 Link to this post

    Hello,

    I answered your question in this thread. If you have more questions I suggest we continue the discussion in it in order to avoid thread duplication.

    Regards,
    Ivan Danchev
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top