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:
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.
When I get to the NodeExpand event I add more nodes but the context menu doesn't show there.
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.
I create the context menu in the .aspx file as follows:
| <telerik:RadTreeView ID="AvailableDataFields_TreeView" runat="server" on OnClientContextMenuItemClicked="ContextMenuClick" OnClientDoubleClick="LinkField"> |
| <ContextMenus> |
| <telerik:RadTreeViewContextMenu runat="server" ID="RadTreeViewContextMenu1" ClickToOpen="True" > |
| <Items> |
| <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> |
| </Items> |
| </telerik:RadTreeViewContextMenu> |
| </ContextMenus> |
| </telerik:RadTreeView> |
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 |
| AvailableDataFields_TreeView.Nodes.Add(oNode) |
| Loop |
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 |
| e.Node.Nodes.Add(oNode) |
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.