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

HeaderContextMenu - Prevent Postback and Customize Options

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karim
Top achievements
Rank 1
Karim asked on 27 Aug 2010, 07:26 PM
I have two questions regarding the HeaderContextMenu in the grid:

1) How do I prevent the menu from posting back on click? I have a client-side event handler:

<HeaderContextMenu OnClientItemClicked="grid_HeaderContextMenu_ClientItemClicked" />

In this handler, I do all the processing I need client-side. However, after that client code executes, the grid still posts back. How do I prevent this? I've tried calling set_cancel(true) on the eventArgs, but the eventArgs in this case doesn't have that method. I've also tried doing the eventArgs.get_domEvent().stopPropagation() and preventDefault() as is shown in other code elsewhere, but that doesn't work either. The postback defeats my whole purpose of doing the processing client-side.

2) How do I customize the context menu options based on the column? I have added two new options to the context menu (which I add during the OnPreRenderComplete). For most of the columns, these two new options are valid, but for one column, they are not valid and so I want to hide them for only that column. How can I do this? It doesn't matter if I do this client-side or server-side.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 01 Sep 2010, 03:15 PM
Hi Karim,

To prevent the menu from posting back on click you could attach OnClientItemClicking event to RadContextMenu and check for the clicked item's index/text to cancel the event which will prevent the postback.

Additionally, more information about how you can customize the header context menu options is available in the forum thread below:
http://www.telerik.com/community/forums/aspnet/grid/radgrid-how-do-i-customize-column-header-context-menu.aspx

Greetings,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Karim
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or