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

ASPxClientGridView.ContextMenuItemClick Event

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

Declaration

ContextMenuItemClick: ASPxClientEvent<ASPxClientGridViewContextMenuItemClickEventHandler<ASPxClientGridView>>

Event Data

The ContextMenuItemClick event's data class is ASPxClientGridViewContextMenuItemClickEventArgs. 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.
objectType Gets which grid element has been right clicked by the user.
processOnServer Specifies whether or not to process the event on the server. Inherited from ASPxClientProcessingModeEventArgs.
usePostBack Specifies whether a postback or a callback is used to finally process the event on the server side.

Remarks

Write a ContextMenuItemClick event handler to perform specific actions on the client side 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.

On the server side, you can respond to a context menu item click using the ASPxGridView.ContextMenuItemClick event.

Example

The code sample below demonstrates how to provide the default grid context menu with two custom items. To add the items to the item collection, the ASPxGridView.FillContextMenuItems event is used. On the client-side, the ASPxClientGridView.ContextMenuItemClick event is handled to respond to a custom item click.

The image below demonstrates a context menu with the custom items.

ASPxGridView_ContextMenuExample

<dx:ASPxGridView ID="MyGridView" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource" ClientInstanceName="myGrid" KeyFieldName="ProductID" OnFillContextMenuItems="MyGridView_FillContextMenuItems">
     <ClientSideEvents ContextMenuItemClick="function(s, e) {
          switch(e.item.name) { 
               case 'SelectAll':
                    myGrid.SelectRows();
                    break;
               case 'DeselectAll':
                    myGrid.UnselectRows();
                    break;
          }
     }" />
     <Columns>
          ...
     </Columns>
     <SettingsBehavior AllowSelectByRowClick="True" />
     <SettingsContextMenu Enabled="True">
     </SettingsContextMenu>
</dx:ASPxGridView>
protected void MyGridView_FillContextMenuItems(object sender, ASPxGridViewContextMenuEventArgs e) {
     e.Items.Add("Select All", "SelectAll");
     e.Items.Add("Deselect All", "DeselectAll");
}
See Also