Handsontable example
HTML
<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" />
<script src="https://handsontable.com/docs/scripts/fixer.js"></script>
<div id="example1" class="hot "></div>
Babel + JSX
import Handsontable from 'handsontable';
import 'handsontable/dist/handsontable.full.min.css';
const sourceDataObject = [
{
category: 'Best Rock Performance',
artist: null,
title: null,
label: null,
__children: [
{
title: "Don't Wanna Fight",
artist: 'Alabama Shakes',
label: 'ATO Records',
},
],
},
{
category: 'Best Metal Performance',
__children: [
{
title: 'Cirice',
artist: 'Ghost',
label: 'Loma Vista Recordings',
},
{
title: 'Identity',
artist: 'August Burns Red',
label: 'Fearless Records',
},
],
},
];
const container = document.querySelector('#example1');
const hot = new Handsontable(container, {
data: sourceDataObject,
preventOverflow: 'horizontal',
rowHeaders: true,
colHeaders: ['Category', 'Artist', 'Title', 'Album', 'Label'],
nestedRows: true,
contextMenu: true,
bindRowsWithHeaders: true,
autoWrapRow: true,
autoWrapCol: true,
manualRowMove: true,
beforeRowMove: (movedRow, finalIndex, dropIndex, movePossible) => {
console.log('beforeRowMove',movedRow, finalIndex, dropIndex, movePossible)
return false;
},
afterRowMove:(movedRows, finalIndex, dropIndex, movePossible, orderChanged) => {
console.log('afterRowMove', movedRows, finalIndex, dropIndex, movePossible, orderChanged)
},
licenseKey: 'non-commercial-and-evaluation',
});