Handsontable example

by handsoncode

HTML

<div id="example"></div>
<script src="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.css">

Babel + JSX

const EMOJI_MAP = new Map([
	['Apple', '🍎'],
  ['Orange', '🍊'],
])
const example = document.getElementById('example');
const hot = new Handsontable(example, {
  data: [
    {
      id: 1,
      item: 'Orange',
    },
  ],
  licenseKey: 'non-commercial-and-evaluation',
  colWidths: 100,
  columns: [
    {
      data: 'id',
    },
    {
      data: 'item',
      type: 'handsontable',
      handsontable: {
        colWidths: 100,
        data: [
          ['Apple'],
          ['Orange']
        ],
        renderer: function(instance, td, row, col, prop, value) {
          Handsontable.renderers.TextRenderer.apply(this, arguments);

          td.innerHTML = `${EMOJI_MAP.get(value)} ${value}`;
        },
      },
    },
  ],
  rowHeaders: true,
  colHeaders: true,
});