Skip to main content

Use select instead of input for edits

When a column in the schema includes an enum property, a drop down menu will appear instead of the normal input or textarea.

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

const app = document.getElementById('app');
const gridElement = document.createElement('div');
const grid = canvasDatagrid({
  parentNode: gridElement,
  data,
  schema: [
    {
      name: 'col1',
      enum: [
        ['foo', 'Foo'],
        ['bar', 'Bar'],
        ['baz', 'Baz'],
      ],
    },
    {
      name: 'col2',
    },
    {
      name: 'col3',
    },
  ],
});

app.append(gridElement);