ASPxGridView.ContextMenuItemClick Event
Fires on the server side when a context menu item has been clicked.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v20.1.dll
NuGet Package: DevExpress.Web
Declaration
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
Write a ContextMenuItemClick event handler to perform specific actions when a context menu item has been 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 thumbnail, 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).
On the client side, you can respond to a context menu item click using the ASPxClientGridView.ContextMenuItemClick event.
Example
protected void MyGridView_FillContextMenuItems(object sender, ASPxGridViewContextMenuEventArgs e) {
e.Items.Add("PDF", "ExportToPDF");
e.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;
}
}