Handsontable example
by JON
HTML
<button class="btn">Add row above</button>
<div id="example1"></div>
CSS
</style><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.min.js"></script><link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.min.css">
JavaScript
var example = document.getElementById('example1');
var hot = new Handsontable(example, {
data: [
['John', 'Smith', 19],
['Brian', 'Adams', 59],
...new Array(40).map(a=>['aaa']),
],
rowHeaders: true,
colHeaders: ['Name', 'Surname', 'Age'],
outsideClickDeselects: false
});
document.querySelector('.btn').addEventListener('click', function() {
var col = hot.countRows();
hot.alter('insert_row', col, 1);
hot.setDataAtCell(col, 0, '-Name-');
hot.setDataAtCell(col, 1, '-Surname-');
hot.setDataAtCell(col, 2, '-Age-')
})