Show context menu on rigth click

4 posts, 0 answers
  1. Shirya
    Shirya avatar
    9 posts
    Member since:
    Jul 2011

    Posted 03 Apr 2012 Link to this post

    Hello everyone,

    I would like to know if it is possible to right click on a radTreeView, WITHOUT slecting a node, and show a menu.
    So far, I've only seen code that show a menu when a node is selected.
    Is it possible?

    Thank you
    Shirya
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Apr 2012 Link to this post

    Hi Shirya,

    Try the following code snippet to show RadContextMenu on right click of a RadTreeView.

    ASPX:
    <telerik:RadTreeView ID="RadTreeView1" runat="server">
     <Nodes>
      <telerik:RadTreeNode Text="RadTreeNode1">
        <Nodes>
         <telerik:RadTreeNode Text="RadTreeNode11">
         </telerik:RadTreeNode>
        </Nodes>
      </telerik:RadTreeNode>
      <telerik:RadTreeNode Text="RadTreeNode2">
        <Nodes>
         <telerik:RadTreeNode Text="RadTreeNode21">
         </telerik:RadTreeNode>
        </Nodes>
      </telerik:RadTreeNode>
      <telerik:RadTreeNode Text="RadTreeNode3">
        <Nodes>
         <telerik:RadTreeNode Text="RadTreeNode31">
         </telerik:RadTreeNode>
        </Nodes>
      </telerik:RadTreeNode>
     </Nodes>
    </telerik:RadTreeView>
    <telerik:RadContextMenu ID="RadContextMenu1" runat="server" >
     <Targets>
      <telerik:ContextMenuControlTarget ControlID="RadTreeView1" />
     </Targets>
     <Items>
      <telerik:RadMenuItem Text="RadMenuItem1">
      </telerik:RadMenuItem>
      <telerik:RadMenuItem Text="RadMenuItem2">
      </telerik:RadMenuItem>
      <telerik:RadMenuItem Text="RadMenuItem3">
      </telerik:RadMenuItem>
     </Items>
    </telerik:RadContextMenu>

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shirya
    Shirya avatar
    9 posts
    Member since:
    Jul 2011

    Posted 04 Apr 2012 Link to this post

    Thank you princy it worked!
    But i noticed that when i right click on a node, the menu apears.
    Is there a way to show the menu only when there a right on the treeview and not on the nodes?
    thank you
    Shirya
  5. Shirya
    Shirya avatar
    9 posts
    Member since:
    Jul 2011

    Posted 04 Apr 2012 Link to this post

    ok, I found the event "OnClientShowing" .
     I'll probably be able to
    cancel the menu showing if no node is selected.
    But if there is  a "cleaner" way to do it, please tell me :)
Back to Top