Handsontable example
by lasteexile
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@12.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@12.1/dist/handsontable.full.min.css" />
<div id="example5" class="hot "></div>
JavaScript
const container = document.getElementById('example5');
const data = [
{ id: 1, name: {first: 'Ted', last: 'Right'}, address: '' },
{ id: 2, name: null }, // name is null and we check if name is available in the data picking function
{ id: 3, name: {first: 'Joan', last: 'Well'}, address: '' }
];
const hot = new Handsontable(container, {
data,
colHeaders: true,
height: 'auto',
width: 'auto',
columns: [
{ data: 'id' },
{ data: (row, value) => {
return row.name ? row.name.first : null; // HERE it is
}
},
{ data: (row, value) => {
return row.name ? row.name.last : null; // And HERE
}
},
{ data: 'address' }
],
minSpareRows: 1,
licenseKey: 'non-commercial-and-evaluation'
});