Skip to main content

Add a column

There is also an insert version of this function.

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

app.append(gridElement);

grid.addColumn({
  defaultValue: function (e) {
    return 'Quux';
  },
  title: 'Bar',
  name: 'bar',
});