Handsontable example
HTML
<button id="btn">Toggle</button>
<div>
<div id="example"></div>
</div>
CSS
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="https://docs.handsontable.com/pro/1.15.0/bower_components/handsontable-pro/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/pro/1.15.0/bower_components/handsontable-pro/dist/handsontable.full.min.css">
JavaScript
$(document).ready(function() {
var example = $('#example');
example.handsontable({
data: Handsontable.helper.createSpreadsheetData(5,10),
colHeaders: true,
rowHeaders: true,
hiddenColumns: true,
colWidths: 60,
nestedHeaders: [
['A', {label: 'B', colspan: 8}, 'C'],
['D', {label: 'E', colspan: 4}, {label: 'F', colspan: 4}, 'G'],
['H', {label: 'I', colspan: 2}, {label: 'J', colspan: 2}, {label: 'K', colspan: 2}, {label: 'L', colspan: 2}, 'M'],
['N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W']
],
collapsibleColumns: [
{row: -4, col: 1, collapsible: true},
{row: -3, col: 1, collapsible: true},
{row: -2, col: 1, collapsible: true},
{row: -2, col: 3, collapsible: true}
]
});
var plugin = example.handsontable('getPlugin', 'collapsibleColumns');
var collapsed = false;
$('#btn').click(function() {
collapsed = !collapsed;
if (collapsed) {
plugin.collapseAll();
} else {
plugin.expandAll();
}
});
});