Handsontable example
HTML
<div id="example1" class="hot handsontable htRowHeaders htColumnHeaders"></div>
CSS
</style><!-- Ugly Hack due to jsFiddle issue --> <script src="https://docs.handsontable.com/pro/1.9.0/bower_components/handsontable-pro/dist/handsontable.full.js"></script> <link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/pro/1.9.0/bower_components/handsontable-pro/dist/handsontable.full.min.css">
JavaScript
document.addEventListener("DOMContentLoaded", function() {
var sourceDataObject = [{
category: 'Best Rock Performance',
artist: null,
title: null,
label: null,
__children: [{
title: 'Don\'t Wanna Fight',
artist: 'Alabama Shakes',
label: 'ATO Records'
}, {
title: 'What Kind Of Man',
artist: 'Florence & The Machine',
label: 'Republic'
}
]
}, {
category: 'Best Metal Performance',
__children: [{
title: 'Cirice',
artist: 'Ghost',
label: 'Loma Vista Recordings'
}, {
title: 'Identity',
artist: 'August Burns Red',
label: 'Fearless Records'
}
]
}],
container = document.getElementById('example1'),
hot;
hot = new Handsontable(container, {
data: sourceDataObject,
rowHeaders: true,
colHeaders: ['Category', 'Artist', 'Title', 'Album', 'Label'],
nestedRows: true,
contextMenu: {
items: [
"add_child",
"detach_from_parent",
"---------",
{
// set the predine menu item key. keep the origianl operation but overwrite the name/disabled.
// !!! this block code is not work !!!
key: "remove_row",
name: "Delete items",
disabled: ()=>{
return hot.getSelectedRangeLast().to.row === 0;
}
},
"---------",
{
key: "indent_plus",
name: 'Indent +',
callback: function() {
alert('+');
}
},
]
}
});
window.hot = hot;
});