The requested page is not available for the requested platform. You are viewing the content for Default platform.

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 handler receives an argument of the ASPxClientGridViewContextMenuItemClickEventArgs type. 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 Gets or sets a value that specifies whether the event should be finally processed on the server side.
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.

Examples

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>
See Also