Skip to main content

Set data after instantiation

A grid is created, then data is set afterwards. You can set data using grid.data = data; at anytime. Data can be an array of objects, an array of arrays or a mixed array of objects, arrays and primitives.

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,
});

app.append(gridElement);

grid.data = data;