Skip to content

Row Context Menu

This example demonstrates how to create a custom row context menu with interactive actions. The menu appears when right-clicking on a row header and provides menu items with actions.

Key * Features:

  • Custom row context menu implementation
  • Actions with visual indicators
  • Styled menu buttons with hover effects

Source code
src/components/row-header/rowHeader.ts
import '@fortawesome/fontawesome-free/css/all.min.css';
import { defineCustomElements } from '@revolist/revogrid/loader';
defineCustomElements();
import { currentTheme, useRandomData } from '../composables/useRandomData';
import { ContextMenuPlugin, RowHeaderPlugin, ColumnStretchPlugin, RowOddPlugin } from '@revolist/revogrid-pro';
import { createContextMenuConfig } from './context-menu.config';
const { createRandomData } = useRandomData();
const { isDark } = currentTheme();
const grid = document.querySelector('revo-grid');
if (grid) {
grid.source = createRandomData(100);
// Define columns
grid.columns = [
{
name: '#',
prop: 'id',
size: 70,
},
{
name: '🍎 Fruit',
prop: 'name',
},
{
name: '💰 Price',
prop: 'price',
},
];
// Define plugin
grid.plugins = [RowHeaderPlugin, ContextMenuPlugin, ColumnStretchPlugin, RowOddPlugin];
// grid.rowHeaders = rowHeaders({ showHeaderFocusBtn: true });
grid.additionalData = {
// Define context menu
rowContextMenu: createContextMenuConfig,
stretch: 'all'
};
// Set theme
grid.theme = isDark() ? 'darkMaterial' : 'material';
}