Skip to main content
A newer version of this page is available. .
Tab

ASPxGridView.ContextMenuItemClick Event

Fires on the server side when a context menu item has been clicked.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v21.2.dll

NuGet Package: DevExpress.Web

Declaration

public event ASPxGridViewContextMenuItemClickEventHandler ContextMenuItemClick

Event Data

The ContextMenuItemClick event's data class is ASPxGridViewContextMenuItemClickEventArgs. The following properties provide information specific to this event:

Property Description
ElementIndex Returns the processed element index.
Handled Specifies whether default context menu item click is handled manually, so no default processing is required.
Item Gets the clicked context menu item.
MenuType Gets the currently displayed context menu‘s type.

Remarks

To allow the grid to raise the server-side ContextMenuItemClick event, handle the client-side ContextMenuItemClick event and set the processOnServer argument property to true.

Handle the ContextMenuItemClick event to perform specific actions when a context menu item is clicked. Note that this event fires immediately after the left mouse button is released. If the button is released when the mouse pointer is not over a context menu item, the event doesn’t fire.

If you want to perform a custom action on a default context menu item click, set the ASPxGridViewContextMenuItemClickEventArgs.Handled property to true to prevent default actions.

You can use the event parameter’s properties to identify the clicked item (ASPxGridViewContextMenuItemClickEventArgs.Item), the menu type (ASPxGridViewContextMenuItemClickEventArgs.MenuType), and determine the index of the right-clicked row or column (ASPxGridViewContextMenuItemClickEventArgs.ElementIndex).

Example

protected void MyGridView_ContextMenuInitialize(object sender, ASPxGridViewContextMenuInitializeEventArgs e) {
     e.ContextMenu.Items.Add("PDF", "ExportToPDF");
     e.ContextMenu.Items.Add("XLS", "ExportToXLS");
}

protected void Grid_ContextMenuItemClick(object sender, ASPxGridViewContextMenuItemClickEventArgs e) {
     switch(e.Item.Name) {
          case "ExportToPDF":
               GridExporter.WritePdfToResponse();
               break;
          case "ExportToXLS":
               GridExporter.WriteXlsToResponse();
               break;
     }
}
See Also