Visiblity of context menu

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    132 posts
    Member since:
    Sep 2007

    Posted 13 Jun 2011 Link to this post

    I have a muti-level tree for which I only want the context menus visible at the end node level.  How would I go about setting the visiblity to false of the context menu for nodes at levels higher up the tree? The nodes at each level have an attribute called "level", I'm wondering is I need to do this on the client side or if I can do it on the server side.

    Thanks
    Jonathan
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 16 Jun 2011 Link to this post

    Hi Jonathan,

    You can easily achieve it by using the following client-side code function (instead of pageLoad eventhandler you could use OnClientContextMenuShowing and implement the below logic there): 
    function pageLoad() {
                    var tree = $find("<%= RadTreeView1.ClientID %>");
                    var allNodes = tree.get_allNodes();
                    for (var i = 0; i < allNodes.length; i++) {
                      var node = allNodes[i];
                       if (node.get_allNodes().length == 0) {
                        //shows the text of all nodes that do not have children nodes
                        //you could call the showContextMenu funtion here
                        alert(node.get_text());
                        }
                    }
                }

    markup
    <telerik:RadTreeView ID="RadTreeView1" runat="server" >
               <Nodes>
                   <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1">
                       <Nodes>
                           <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1" Category="context">
                           </telerik:RadTreeNode>
                           <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2" Category="context">
                               <Nodes>
                                   <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">
                                   </telerik:RadTreeNode>
                                   <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2">
                                   </telerik:RadTreeNode>
                               </Nodes>
                           </telerik:RadTreeNode>
                           <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 3">
                           </telerik:RadTreeNode>
                       </Nodes>
                   </telerik:RadTreeNode>
                   <telerik:RadTreeNode runat="server" Text="Root RadTreeNode2">
                   </telerik:RadTreeNode>
                   <telerik:RadTreeNode runat="server" Text="Root RadTreeNode3">
                   </telerik:RadTreeNode>
                   <telerik:RadTreeNode runat="server" Text="Root RadTreeNode4">
                       <Nodes>
                           <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">
                           </telerik:RadTreeNode>
                           <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2">
                           </telerik:RadTreeNode>
                       </Nodes>
                   </telerik:RadTreeNode>
                   <telerik:RadTreeNode runat="server" Text="Root RadTreeNode5">
                   </telerik:RadTreeNode>
               </Nodes>
           </telerik:RadTreeView>


    All the best,
    Kate
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top