# Cell context menus

A cell's context menu offers actions such as Copy, Copy row, and Export for the current location. Also provide toolbar or keyboard access to frequently used features.

Canonical: https://grid.syidax.com/docs/features/context-menu/

<a id="understand"></a>

## How it works and when to use it

contextMenuItemsCallback replaces the default menu rather than appending to it. If default actions are needed, include them in the returned list or offer separate buttons.

Using this feature in a product requires the Pro package and a valid license. Matching setting names do not enable Pro features in Community.

In the code, grid is the Grid element prepared in the installation chapter. Check each example's data and settings, and implement the app functions and server endpoints for your project.

- [Installation and integration · Shared sample data](https://grid.syidax.com/docs/guides/getting-started.md)

<a id="example-1"></a>

## Example 1. Default context menu

Enable the option to use the default items.

```javascript
grid.contextMenu = true;
```

Verify the result: Right-click a cell to inspect the default actions for that cell or row.

<a id="example-2"></a>

## Example 2. Business-specific menu

Menu labels describe the task; action performs the actual work.

```javascript
grid.contextMenuItemsCallback = () => [{
  id: 'inspect-order', label: 'Inspect order',
  action: context => console.log(context),
}];
```

Verify the result: One business action replaces the default items. Read the row and column from context to open the app's detail view.

<a id="example-3"></a>

## Example 3. Inspect menu configuration in advance

Read the menu for the product cell in the first displayed row.

```javascript
console.log(await grid.getContextMenuItems({ rowIndex: 0, field: 'product' }));
```

Verify the result: Check which items appear and which are conditionally disabled. Hiding a menu does not replace server authorization checks.

<a id="pitfalls"></a>

## Combining features and troubleshooting

Do not retain display indices for later use in custom menu actions. Read a stable row ID when starting the action.

Provide access to essential actions in environments without right-click.

<a id="related-api"></a>

## APIs used by this feature

- [contextMenu](https://grid.syidax.com/docs/options/contextMenu.md) — Displays a cell context menu. Use built-in copy, row copy, and CSV actions or replace the list through a callback.
- [contextMenuItemsCallback](https://grid.syidax.com/docs/options/contextMenuItemsCallback.md) — Returns cell context-menu items. Replaces the entire default list rather than appending to it.
- [getContextMenuItems](https://grid.syidax.com/docs/methods/getContextMenuItems.md) — Calculates context-menu items for a displayed row and field.
- [contextMenuItemClicked](https://grid.syidax.com/docs/events/contextMenuItemClicked.md) — Emitted when a cell context-menu item runs. Read its item ID and target cell position.

<a id="next"></a>

## Related reading

- [How rows, columns, and IDs relate](https://grid.syidax.com/docs/guides/concepts.md)
- [Connect results and events](https://grid.syidax.com/docs/guides/data-event-access.md)
- [Explore in Features](https://grid.syidax.com/grid/context-menu) — The guide describes which interactions are available to try.
