This is a migrated thread and some comments may be shown as answers.

[Solved] ContextMenu in ajax treeview seemingly ignored

1 Answer 123 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Phil C
Top achievements
Rank 2
Phil C asked on 19 Jun 2008, 05:41 PM
Hi, I can't get your Treeview ContextMenu to work under prometheus, have tried another thread for XML loading so now using straight code (another thread has working example using declarative control-side contextmenus, so at least I know that works!).

Using similar code to the help file, can see the population code runs fine through debug, however on the page there is nothing on a right-click (although it looks like they're in the javascript).

        Public Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles MyBase.Load 
            If Not Page.IsPostBack Then 
                cntxMenuUserGroup = New RadTreeViewContextMenu() 
                cntxMenuUserGroup.ID = "UGM_UserGroup" 
                Dim menuItem1 As New RadMenuItem() 
                menuItem1.Text = "Remove User From UserGroup" 
                menuItem1.Value = "UGM_User_Remove" 
                cntxMenuUserGroup.Items.Add(menuItem1) 
                Dim menuItem2 As New RadMenuItem() 
                menuItem2.Text = "Add User To UserGroup" 
                menuItem2.Value = "UGM_User_Add" 
                cntxMenuUserGroup.Items.Add(menuItem2) 
                RadTree1.ContextMenus.Add(cntxMenuUserGroup) 
                BuildTree() 
            End If 
        End Sub 
 
        Public Sub BuildTree() 
            dbCon.Open() 
            Dim adapter As New SqlDataAdapter("SELECT blah blah", dbCon) 
            Dim ds As New DataSet 
            adapter.Fill(ds) 
            Dim row As DataRow 
            For Each row In ds.Tables(0).Rows 
                Dim node As New Telerik.Web.UI.RadTreeNode 
                node.Text = CStr(row("UDesc")) 
                node.Value = CStr(row("UVal")) 
                node.ContextMenuID = "cntxMenuUserGroup" 
                RadTree1.Nodes.Add(node) 
                If row("NumRecs") > 0 Then 
                    node.ExpandMode = Telerik.Web.UI.TreeNodeExpandMode.ServerSide 
                Else 
                    node.ExpandMode = Telerik.Web.UI.TreeNodeExpandMode.ClientSide 
                End If 
            Next row 
            dbCon.Close() 
        End Sub 

Why does
                node.ContextMenuID = "cntxMenuUserGroup" 
seem to be ignored? I tried swapping in "UGM_UserGroup" in case of helpfile error but still same.

1 Answer, 1 is accepted

Sort by
0
Phil C
Top achievements
Rank 2
answered on 20 Jun 2008, 10:26 AM
Fixed it - as noted, the menus were in the javascript but not coming out on right-click. However, I noticed some table, panel and div clashes wrapping up the control, i fixed those so there was no intellisense warning in VS2008 and hey presto, context menus are working.

So, make sure there's nothing wrong there first if you have this issue. Dowhh!
Tags
TreeView
Asked by
Phil C
Top achievements
Rank 2
Answers by
Phil C
Top achievements
Rank 2
Share this question
or