Skip to main content

Remove context menu items

You can mutate the existing items in the context menu.

import canvasDatagrid from 'canvas-datagrid';
import data from '/data.json';

const app = document.getElementById('app');
const gridElement = document.createElement('div');
const grid = canvasDatagrid({
  parentNode: gridElement,
  data,
});

grid.addEventListener('contextmenu', function (e) {
  e.items.splice(0, e.items.length);
  e.items.push({
    title: 'Just me now',
  });
});

app.append(gridElement);