JavaScript Data Grid上下文菜单
通过打开上下文菜单,可以快速访问删除行、插入列或复制数据等上下文操作。
带有默认选项的上下文菜单
使用默认配置启用上下文菜单:
contextMenu: true,
要查看上下文菜单,在单元格上右键单击:
带有选定选项的上下文菜单
您可以通过将 contextMenu 选项作为键的数组传递来定义菜单中的项目:
要查看上下文菜单,右键单击单元格:
带完全自定义配置的上下文菜单
本示例展示了如何:
为所有选项添加通用回调
动态禁用选项
为预定义选项设置自定义文本
添加自己的自定义选项
为特定选项添加回调函数
要查看上下文菜单,右键单击单元格:
相关键盘快捷键
| Windows | macOS | 操作 | Excel | 工作表 |
|---|---|---|---|---|
| Ctrl+Shift+\ or Shift+F10 | Cmd+Shift+\ or Shift+F10 | 打开上下文菜单 | ✗ | ✓ |
| 箭头键 | 箭头键 | 将一个可用的菜单项向上、向下、向左或向右移动 | ✓ | ✓ |
| Page Up | Page Up | Move to the first visible item of the context menu or submenu | ✓ | ✗ |
| Page Down | Page Down | Move to the last visible item of the context menu or submenu | ✓ | ✗ |
| Escape | Escape | Close the context menu or submenu | ✓ | ✓ |
| Enter | Enter | Run the action of the selected menu item | ✓ | ✗ |
Related articles
Related guides
Related blog articles
Related API reference
- Configuration options:
- Hooks:
- Plugins:
