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

How to disable context menu in node with no child

1 Answer 174 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Santanu
Top achievements
Rank 1
Santanu asked on 24 Oct 2015, 09:51 AM

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

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 28 Oct 2015, 03:03 PM
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
Tags
TreeView
Asked by
Santanu
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or