I have a content page that contains a RadSplitter. On the left of the splitter is a RadPane with a Radtreeview. the treeview definition is below.
As you can see I have subscribed to the Node Expand event of the server side. There is a lot of node building code in here so I won't post it all. however a single child node is successfully created (See image nodeDetail.gif). This image shows the Id from the menu
The RadTreeContextMenu is also generated. See attachment MenuDetail.gif this image shows the detail of the menu including the fact that it has childitems.
The process is
When I run this the new node shows perfectly but the menu does not. It shows the standard IE Context menu See result.gif.
The code for building the menu is
I have tried this with and without the view state set and the ClientIDMode and still cannot get it to show,
Questions (in order of priority)
<
telerik:RadTreeView
ID
=
"rtOutline"
runat
=
"server"
AccessKey
=
"w"
CausesValidation
=
"False"
EnableDragAndDrop
=
"True"
EnableDragAndDropBetweenNodes
=
"True"
EnableViewState
=
"True"
CollapseAnimation-Type
=
"None"
ExpandAnimation-Type
=
"None"
OnNodeExpand
=
"rtOutline_NodeExpand"
>
<
ContextMenus
>
<
telerik:RadTreeViewContextMenu
ID
=
"ElementMenu"
runat
=
"server"
EnableAutoScroll
=
"True"
>
</
telerik:RadTreeViewContextMenu
>
</
ContextMenus
>
<
ExpandAnimation
Type
=
"None"
/>
</
telerik:RadTreeView
>
As you can see I have subscribed to the Node Expand event of the server side. There is a lot of node building code in here so I won't post it all. however a single child node is successfully created (See image nodeDetail.gif). This image shows the Id from the menu
Protected Sub rtOutline_NodeExpand(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles rtOutline.NodeExpand
Dim newNode As RadTreeNode = NodeControl.LoadNodes(e.Node, rtOutline)
e.Node = newNode
End Sub
The RadTreeContextMenu is also generated. See attachment MenuDetail.gif this image shows the detail of the menu including the fact that it has childitems.
The process is
- The node is generated
- the node id is passed into a function to generate the RadTreeContextMenu
and the menu is returned. - the menu is added to the RadTreeView
- the menu Id is assigned to the contextrmenuid property
- the node is then added to its parent.
Dim nodeMenu As RadTreeViewContextMenu = myMenuBuilder.BuildMenu(targetNode)
nodeTreeview.ContextMenus.Add(nodeMenu)
targetNode.ContextMenuId = nodeMenu.ID
- the parent is returned to the controlling function and attached to the tree
When I run this the new node shows perfectly but the menu does not. It shows the standard IE Context menu See result.gif.
The code for building the menu is
Public Function BuildMenu(ByVal myNode As RadTreeNode) As RadTreeViewContextMenu
Dim myMenu As New RadTreeViewContextMenu
Dim menuElements As List(Of ElementWrapper) = LoadElements(myNode.Attributes("IID"))
Dim helpItem As New RadMenuItem
Dim iLoopCounter As Int32 = 0
'***** Loading Menu Item
Dim mnuLoading As New RadMenuItem
mnuLoading.Text = "Loading..."
mnuLoading.Enabled = False
myMenu.Items.Add(mnuLoading)
For Each a As ElementWrapper In menuElements
Dim newMenuItem As New RadMenuItem
newMenuItem.Text = a.Text
newMenuItem.EnableImageSprite = a.Enabled
newMenuItem.Attributes.Add("Command", a.Cmd)
newMenuItem.Attributes.Add("CommandArg", a.CmdArg)
newMenuItem.Attributes.Add("IID", myNode.Attributes("IID"))
If a.Cmd = "HELP_MENU" Then
helpItem = newMenuItem
Dim aSplitter = New RadMenuItem
aSplitter.IsSeparator = True
Dim myStyle As New Style
myStyle.Width = Unit.Pixel(125)
aSplitter.ApplyStyle(myStyle)
myMenu.Items.Add(aSplitter)
ElseIf a.Cmd = "HELP_ITEM" Then
helpItem.Items.Add(newMenuItem)
Else
myMenu.Items.Add(newMenuItem)
End If
iLoopCounter = iLoopCounter + 1
Next
Dim newHeight As Int32 = iLoopCounter * 25
If newHeight > 250 Then newHeight = 250
myMenu.AutoScrollMinimumHeight = newHeight
myMenu.ID = "mnu" & myNode.Attributes("IID")
myMenu.EnableViewState = True
myMenu.ClientIDMode = ClientIDMode.Static
Return myMenu
End Function
I have tried this with and without the view state set and the ClientIDMode and still cannot get it to show,
Questions (in order of priority)
- Can you please advise why the menu would not activate?
- Why would the menu not be maintained if the viewstate is enabled. this happens if I click on the node after it has been generated