3 Answers, 1 is accepted
0
Accepted

Princy
Top achievements
Rank 2
answered on 02 Jul 2010, 12:19 PM
Hello Jing,
You can add ContextMenu on anywhere in the grid by adding <Targets> to RadContextMenu. You can also differentiate the ContextMenu items in grid row and empty space by setting the visibility of appropriate ContextMenuItem in 'OnClientShowing' and OnRowContextMenu client event. Here is the code sample that I tried for a similar kind of scenario.
ASPX:
Java Script:
Thanks,
Princy.
You can add ContextMenu on anywhere in the grid by adding <Targets> to RadContextMenu. You can also differentiate the ContextMenu items in grid row and empty space by setting the visibility of appropriate ContextMenuItem in 'OnClientShowing' and OnRowContextMenu client event. Here is the code sample that I tried for a similar kind of scenario.
ASPX:
<telerik:RadGrid ID="RadGrid1" ........................... |
<MasterTableView |
................................................ |
</MasterTableView> |
<ClientSettings> |
<ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents> |
</ClientSettings> |
</telerik:RadGrid> |
<telerik:RadContextMenu OnClientShowing="OnClientShowing" ID="RadMenu1" runat="server"> |
<Items> |
<telerik:RadMenuItem Text="Edit" /> |
<telerik:RadMenuItem Text="Delete" /> |
<telerik:RadMenuItem Text="Add" /> |
</Items> |
<Targets> |
<telerik:ContextMenuControlTarget ControlID="RadGrid1" /> |
</Targets> |
</telerik:RadContextMenu> |
Java Script:
<script type="text/javascript"> |
function OnClientShowing(sender, args) |
{ |
var menu = sender; |
menu.findItemByText("Add").set_visible(true); |
menu.findItemByText("Edit").set_visible(false); |
menu.findItemByText("Delete").set_visible(false); |
} |
function RowContextMenu(sender, eventArgs) |
{ |
var menu = $find("<%=RadMenu1.ClientID %>"); |
menu.findItemByText("Add").set_visible(false); |
menu.findItemByText("Edit").set_visible(true); |
menu.findItemByText("Delete").set_visible(true); |
................................. |
} |
</script> |
Thanks,
Princy.
0

jing
Top achievements
Rank 1
answered on 19 Jul 2010, 11:16 AM
How do I able to right click with the context menu after a ajax postback? I was not able to do up this part.
0

jing
Top achievements
Rank 1
answered on 21 Jul 2010, 06:04 AM
Update. Please ignore this post and the post before this. I have been using 2 context menus.
---
I got this part done by add the contextmenu control to the ajaxmanager so that if there is a postback done, i can still able to right click anywhere on the Grid1 with the context menu.
---
I got this part done by add the contextmenu control to the ajaxmanager so that if there is a postback done, i can still able to right click anywhere on the Grid1 with the context menu.
<
telerik:RadAjaxManager
ID
=
"AjaxManager"
runat
=
"server"
>
<
telerik:AjaxSetting
AjaxControlID
=
"TreeView1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"Grid1"
LoadingPanelID
=
"AjaxLoadingPanel"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"ContextMenu1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
telerik:RadAjaxManager
>