How to disable context menu in node with no child

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

    Posted 24 Oct 2015 Link to this post

    Hi

     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%" >
                                                        <DataBindings>
                                                            <telerik:RadTreeNodeBinding Expanded="True" />
                                                        </DataBindings>
                                                       <ContextMenus>
                                                       <telerik:RadTreeViewContextMenu ID="MainContextMenu" runat="server">
                                                            <Items>
                                                                <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>
                                                            </Items>
                                                        </telerik:RadTreeViewContextMenu>
                                                       </ContextMenus>
                                                    </telerik:RadTreeView>

      

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

    Can anyone help on this.

     

    Regards

    Santanu

  2. Nencho
    Admin
    Nencho avatar
    1457 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)
                        menu.findItemByValue("AddUserUnderThisTeam").disable();
             
                }
    </script>


    Regards,
    Nencho
    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