This is a migrated thread and some comments may be shown as answers.

RadMenu Add Child Menu Item to Parent Menu Item

1 Answer 122 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 13 Aug 2015, 01:26 AM

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>

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 13 Aug 2015, 04:29 PM
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
Tags
Menu
Asked by
Joe
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or