Skip to content

ContextMenuItem@sheetwrite/core

On this page

Built-in, separator, or custom callback row in the right-click menu.

Examples

import type { ContextMenuItem, GridConfig } from "@sheetwrite/core";
const total: ContextMenuItem = {
id: "total",
label: "Show total",
onClick(grid) { window.alert(String(grid.aggregate(0, "sum"))); },
};
const config: GridConfig = { contextMenu: [total, { action: "separator" }, { action: "copy" }] };

See also

Members 7

id Stable host identifier, exposed as data-context-menu-item.
id?: string;
action Built-in action to bind (or "separator").

Built-in action to bind (or "separator"). Omit when supplying `onClick`.

onClick Custom click handler; receives the grid and the right-clicked cell (null if none).
onClick?: (grid: Grid, cell: CellAddress | null) => void;
label Menu row text. Defaults per action.
label?: string;
shortcut A bound action name or a custom key combination.

A bound action name or a custom key combination. An explicit combination registers `onClick` as a keyboard command; action names only reference the existing built-in binding. Both forms display platform-aware labels. For example, `shortcut: "copy"` follows the configured Copy binding, while `shortcut: "Mod+Shift+K"` binds this item's `onClick` callback. See KeyboardOptions for built-in action overrides.

visible Static or request-aware visibility.
visible?: boolean | ((context: ContextMenuContext) => boolean);

Static or request-aware visibility. Hidden separators are normalized.

disabled Static or context-aware disabled state.
disabled?: boolean | ((context: ContextMenuContext) => boolean);

Declaration

View full TypeScript declaration
export interface ContextMenuItem {
id?: string;
onClick?: (grid: Grid, cell: CellAddress | null) => void;
label?: string;
visible?: boolean | ((context: ContextMenuContext) => boolean);
disabled?: boolean | ((context: ContextMenuContext) => boolean);
}

Referenced by

Workspace packages depending on @sheetwrite/core

  • @sheetwrite/benchdependency
  • @sheetwrite/docs-startdependency
  • @sheetwrite/reactdependency
  • @sheetwrite/sveltedependency
  • @sheetwrite/vuedependency
  • @sheetwrite/xlsxdependency

Public exports naming ContextMenuItem

Documentation