Radtreeview contextmenu on child node(Level=2).

2 posts, 0 answers
  1. Nagendra
    Nagendra avatar
    35 posts
    Member since:
    Jan 2011

    Posted 29 Jul 2011 Link to this post

    Hi,

        In my page i have radtreeview, when i right click on child node(Lot 5) i am getting context menu "Start job" i want this option only.
        But when i am right click on parent node(Phase 1) of Lot 5 i am getting same "Start Job" context menu. I don't want  this option.

        Please find the attached screen shots.

        Here is my code.
    Protected Sub contextmenu()
        Dim contextMenu1 As New RadTreeViewContextMenu()
        contextMenu1.ID = "contextMenu1"
        Dim menuItem1 As New RadMenuItem()
        menuItem1.Text = "Start Job"
        contextMenu1.Items.Add(menuItem1)
        RadTreeView1.ContextMenus.Add(contextMenu1)
        Dim contextMenu2 As New RadTreeViewContextMenu()
        RadTreeView1.ContextMenus.Add(contextMenu2)
        For Each node As RadTreeNode In RadTreeView1.GetAllNodes()
            node.ContextMenuID = IIf((node.Text = node_text.Text And node.Level = 2), "contextMenu1", "contextMenu2")
        Next
    End Sub
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Aug 2011 Link to this post

    Hello Nagendra,

    Try the following javascript to get the Context Menu in parent node only.
    JS:
    <script type="text/javascript">
    function onClientContextMenuShowing(sender, args)
    {
    var node = args.get_node();
      if(node.get_text()!="P1 - Phase1")
      {
         args.set_cancel(true);
      }
    }
    </script>

    Thanks,
    Shinu.
Back to Top