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

Show context menu on rigth click

3 Answers 115 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Shirya
Top achievements
Rank 1
Shirya asked on 03 Apr 2012, 03:54 PM
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

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Apr 2012, 06:25 AM
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.
0
Shirya
Top achievements
Rank 1
answered on 04 Apr 2012, 02:09 PM
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
0
Shirya
Top achievements
Rank 1
answered on 04 Apr 2012, 02:27 PM
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 :)
Tags
TreeView
Asked by
Shirya
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Shirya
Top achievements
Rank 1
Share this question
or