Asynchronous context items
Instead of an array, you can use a function that invokes a callback. When you invoke the callback you pass an array to it to add items to the context menu asynchronously.
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.push({ title: 'Asynchronous child context menu item', items: function (callback) { setTimeout(function () { callback([ { title: 'I was added later', click: function () { return; }, }, ]); }, 500); }, }); }); app.append(gridElement);