Have a problem with the context menu on the radmenucontrol
The contextmenu works fine but here is the scenario
MENU ITEM 1 MENU ITEM 2 MENU ITEM 3
- SUBMENU ITEM 2-1 -SUBMENU ITEM 3-1
- SUBMENU ITEM 3-2
Ok, the context menu will work on the lowerst item in the tree
In this case it will work on
- MENU ITEM 1
- SUBMENU ITEM 2-1
- SUBMENU ITEM 3-2
But all other items the context menu is disabled for some reason.
Here is the code.
ASPX :
VB, just for info but this works
But i think there is something wrong with this line :
The contextmenu works fine but here is the scenario
MENU ITEM 1 MENU ITEM 2 MENU ITEM 3
- SUBMENU ITEM 2-1 -SUBMENU ITEM 3-1
- SUBMENU ITEM 3-2
Ok, the context menu will work on the lowerst item in the tree
In this case it will work on
- MENU ITEM 1
- SUBMENU ITEM 2-1
- SUBMENU ITEM 3-2
But all other items the context menu is disabled for some reason.
Here is the code.
ASPX :
| <telerik:RadContextMenu ID="RadContextTopMenu" runat="server" OnClientShowing="topmenuShowing" OnItemClick="RadTopMenu1_ItemClick" Skin="Windows7"> |
| <Items> |
| <telerik:RadMenuItem runat="server" Text="Menupagina toevoegen"> |
| </telerik:RadMenuItem> |
| <telerik:RadMenuItem runat="server" Text="SubPagina Toevoegen"> |
| </telerik:RadMenuItem> |
| <telerik:RadMenuItem runat="server" Text="Pagina Wijzigen"> |
| </telerik:RadMenuItem> |
| <telerik:RadMenuItem runat="server" Text="Pagina Verwijderen"> |
| </telerik:RadMenuItem> |
| </Items> |
| <Targets> |
| <telerik:ContextMenuControlTarget ControlID="RadTopMenu1" /> |
| </Targets> |
| </telerik:RadContextMenu> |
| <telerik:RadScriptBlock runat="server" ID="RadScriptBlock2"> |
| <script type="text/javascript"> |
| function topmenuShowing(sender, args) { |
| var target = args.get_targetElement(); |
| if (target.className != "rmText") { |
| args.set_cancel(true); |
| } |
| else { |
| var panelBarItem = $find("<%=RadTopMenu1.ClientID %>").findItemByText(target.innerHTML); |
| sender.trackChanges(); |
| sender.get_items().getItem(0).get_attributes().setAttribute("mItem", panelBarItem.get_attributes().getAttribute("PageID")); |
| sender.commitChanges(); |
| } |
| sender.hide(); |
| } |
| </script> |
| </telerik:RadScriptBlock> |
| <telerik:RadWindowManager ID="topMenuradwindow" EnableViewState="false" runat="server" Skin="Windows7"> |
| </telerik:RadWindowManager> |
| <telerik:RadMenu ID="RadTopMenu1" runat="server" OnItemClick="Click" Style="z-index: 2;" /> |
VB, just for info but this works
| Protected Sub RadTopMenu1_ItemClick(ByVal sender As Object, ByVal e As RadMenuEventArgs) |
| Private Sub BindToDataSet() |
| Dim adapter As New SqlDataAdapter("SELECT * FROM TblPages where MenuID = " + MenuIDvalue, _ |
| ConfigurationManager.ConnectionStrings("Varodb").ConnectionString) |
| Dim Menu As New DataSet() |
| adapter.Fill(Menu) |
| RadTopMenu1.DataTextField = "Pagename" |
| RadTopMenu1.DataFieldID = "ID" |
| RadTopMenu1.DataFieldParentID = "PageID" |
| RadTopMenu1.DataSource = Menu |
| RadTopMenu1.DataBind() |
| End Sub |
| Protected Sub RadMenu1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles RadTopMenu1.ItemDataBound |
| Dim dataRow As DataRowView = DirectCast(e.Item.DataItem, DataRowView) |
| e.Item.Attributes("PageID") = dataRow("ID").ToString() |
| End Sub |
| Dim MenuitemValue As String = RadContextTopMenu.Items(0).Attributes("mItem").ToString() |
| Select Case e.Item.Text |
| Case "Menupagina toevoegen" |
| 'some code |
| Case "SubPagina Toevoegen" |
| 'some code |
| Exit Select |
| Case "Pagina Wijzigen" |
| 'some code |
| Exit Select |
| Case "Pagina Verwijderen" |
| 'some code |
| Exit Select |
| End Select |
| End Sub |
But i think there is something wrong with this line :
sender.get_items().getItem(0).get_attributes().setAttribute(
"mItem", panelBarItem.get_attributes().getAttribute("PageID"));
Anyone has an idea ?