How to add Context menu to a TreeView Context Menu

2 posts, 0 answers
  1. Dhamodharan
    Dhamodharan avatar
    300 posts
    Member since:
    Sep 2010

    Posted 23 Jan 2013 Link to this post

    I need to add a context menu to a treeviewcontext menu in Ajax. either to right on the tree view context or in the Menu format. The details to be bind from database.

  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    1966 posts

    Posted 28 Jan 2013 Link to this post


    An easy and convenient way of adding dynamically a menu item to existing RadTreeViewContext menu would be to use the RadTreeView OnContextMenuItemClick server-side event handler as shown in the code snippet below:

    //markup code

    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick">
                    <telerik:RadMenuItem Text="Context Menu 1"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Context Menu 2"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="AddNewItem"></telerik:RadMenuItem>

    //code behind

    protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        if (e.MenuItem.Text == "AddNewItem")
               //here goes your custom logic of accessing the data base and retrieve
               // new menu item details
            RadTreeView1.ContextMenus[0].Items.Add(new RadMenuItem("Dynamically added"));

    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top