How to disable context menu in node with no child

2 posts, 0 answers
  1. Santanu
    Santanu avatar
    7 posts
    Member since:
    Mar 2010

    Posted 24 Oct 2015 Link to this post


     I have a tree-view control which populates the data from database, On that tree-view I also have a context menu Now I want to make viable off of one menu on the context menu if the node is last node (means no more child node). Given bellow the is rad tree:


    <telerik:RadTreeView ID="RadTreeView1" runat="server" Width="90%" >
                                                            <telerik:RadTreeNodeBinding Expanded="True" />
                                                       <telerik:RadTreeViewContextMenu ID="MainContextMenu" runat="server">
                                                                <telerik:RadMenuItem Value="CreateNewTeam" Text="Create New Team" ImageUrl="../../../../image/RadControls/Grid/Skins/Default/SinglePlus.gif"></telerik:RadMenuItem>
                                                                <telerik:RadMenuItem Value="AddUserUnderThisTeam" Text="Add User" ImageUrl="../../../../image/RadControls/Grid/Skins/Default/Insert.gif"></telerik:RadMenuItem>


    I want to disable AddUserUnderThisTeam if the node is the last node (no more child)

    Can anyone help on this.




  2. Nencho
    Nencho avatar
    1777 posts

    Posted 28 Oct 2015 Link to this post

    Hello Santanu,

    In order to disable certain item from the ContextMenu, base on the node, over which it is showing, you can handle the OnClientContextMenuShowing client-side event of the RadTreeView and implement the following functionality:

      <script type="text/javascript">
                function OnClientContextMenuShowing(sender, args) {
                    if (args.get_node().get_nodes().get_count() == 0)

    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
Back to Top