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 permilRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(this, [instance, td, row, col, prop, value, cellProperties]);
td.innerHTML = `${value} ‰`;
}
const example = document.getElementById('example');
const hot = new Handsontable(example, {
data: [
{ name: 'Population Mercury 1', positive: 3.3 },
{ name: 'Population Mercury 2', positive: 2.36 },
{ name: 'Population Mars 1', positive: 2 },
{ name: 'Population Mars 2', positive: 1.5 },
{ name: 'Population Jupiter 1', positive: 3.43 },
],
licenseKey: 'non-commercial-and-evaluation',
rowHeaders: true,
colHeaders: true,
columns: [
{
title: 'Population name',
data: 'name',
},
{
title: 'Positive reactions',
data: 'positive',
type: 'numeric',
renderer: permilRenderer
}
]
});