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

function bitcoinRenderer(instance, td, row, col, prop, value, cellProperties) {
  Handsontable.renderers.NumericRenderer.apply(this, [instance, td, row, col, prop, value, cellProperties]);

  td.innerHTML = `${value} &#x20BF;`;
}

const example = document.getElementById('example');
const hot = new Handsontable(example, {
  data: [
  	{ name: 'San Marino ap.1', value: 54 },
  	{ name: 'Casa de Sol', value: 50 },
  	{ name: 'House on Mars', value: 25 },
  ],
  licenseKey: 'non-commercial-and-evaluation',
  rowHeaders: true,
  colHeaders: true,
  columns: [
  	{
    	data: 'name',
      title: 'Property name',
    },
    {
    	data: 'value',
      title: 'Value (Bitcoin)',
      type: 'numeric',
      renderer: bitcoinRenderer
    }
  ]
});