Skip to main content

Draw HTML via data type

This draws HTML into an SVG object, takes a picture of it and caches it into the grid, then draws it into the cell. In other words, it works, but it\'s slow.

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.schema = [
  { name: 'id', type: 'number' },
  { name: 'offendit', type: 'html' },
];
grid.data = [
  { id: 0, offendit: 'number' },
  { id: 0, offendit: 'number' },
];
grid.draw();