Context Menu Displaying on Root Nodes

2 posts, 1 answers
  1. Lynne
    Lynne avatar
    13 posts
    Member since:
    Apr 2008

    Posted 17 Sep 2009 Link to this post

    I want the context menu to show on nodes that are dynamically created in the _TreeView_NodeExpand event.  The context menu is displaying instead only on the root node which I don't want.  By the way, I have the very latest version of the ASP.NET AJAX controls.

    I create the context menu in the .aspx file as follows:


                              <telerik:RadTreeView  ID="AvailableDataFields_TreeView" runat="server"  on  OnClientContextMenuItemClicked="ContextMenuClick"   OnClientDoubleClick="LinkField">  
                                   <telerik:RadTreeViewContextMenu runat="server" ID="RadTreeViewContextMenu1" ClickToOpen="True" > 
                                        <telerik:RadMenuItem   ImageUrl="../../images/Data.gif" Text="Add to Data Tab"></telerik:RadMenuItem> 
                                        <telerik:RadMenuItem ImageUrl="../../images/Filter.gif" Text="Add to Filter Tab"></telerik:RadMenuItem> 
                                        <telerik:RadMenuItem ImageUrl="../../images/Sort.gif" Text="Add to Order Tab"></telerik:RadMenuItem> 

    Then in the Page_Load event I add nodes to the tree dynamically and this node level displays the context menu which I don't want.
                oData = oCmd.ExecuteReader  
                Do While oData.Read  
                    Dim oNode As New RadTreeNode  
                    sDesc = oData("Description").ToString  
                    If sDesc.Length > 50 Then  
                        sDescsDesc = sDesc.Substring(0, 49) & "..."  
                    End If  
                    With oNode  
                        .ToolTip = "Alias: " & oData("Alias").ToString & vbCrLf & "Description: " & sDesc  
                        .Value = oData("TableID")  
                        .ExpandMode = TreeNodeExpandMode.ServerSideCallBack  
                        .Text = oData("Alias").ToString  
                    End With  

    When I get to the NodeExpand event I add more nodes but the context menu doesn't show there.

                Do While oData.Read  
                    Dim oNode As New RadTreeNode  
                    With oNode  
                        .ToolTip = sTooltip 
                        .Text = oData("Alias").ToString  
                        .ExpandMode = TreeNodeExpandMode.ClientSide  
                        .Value = oData("FieldID")  
                        .ContextMenuID = "Report" 
                        .CssClass = "TreeInnerNode" 
                        .HoveredCssClass = "TreeInnerNodeOver" 
                        .EnableContextMenu = True 
                    End With  

    What should I do to display the nodes on the correct level?  If I put .EnableContextMenu = false on the first level then there are no context menus anywhere on the tree.

  2. Answer
    Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 18 Sep 2009 Link to this post

    Hi Lynne Barton,

    Please find attached a sample project that works as expected.

    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top