JavaScript
document.addEventListener("DOMContentLoaded", function() {
var
hiddenData = [
['', 'Kia', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
['2012', 10, 11, 12, 13, 15, 16],
['2013', 10, 11, 12, 13, 15, 16],
['2014', 10, 11, 12, 13, 15, 16],
['2015', 10, 11, 12, 13, 15, 16],
['2016', 10, 11, 12, 13, 15, 16]
],
container = document.getElementById('example2'),
hot2;
hot2 = new Handsontable(container, {
data: hiddenData,
colHeaders: true,
minSpareRows: 1,
columns: [
{data: 0},
{data: 2},
{data: 3},
{data: 4},
{data: 5},
{data: 6}
],
columnSummary: [
{
destinationRow: 0,
destinationColumn:1,
reversedRowCoords: true,
type: 'sum',
forceNumeric: true
}, {
destinationRow: 0,
destinationColumn: 2,
reversedRowCoords: true,
type: 'sum',
forceNumeric: true
}, {
destinationRow: 0,
destinationColumn: 3,
reversedRowCoords: true,
type: 'sum',
forceNumeric: true
}, {
destinationRow: 0,
destinationColumn: 4,
reversedRowCoords: true,
type: 'sum',
forceNumeric: true
}, {
destinationRow: 0,
destinationColumn: 5,
reversedRowCoords: true,
type: 'sum',
forceNumeric: true
}]
});
function bindDumpButton() {
if (typeof Handsontable === "undefined") {
return;
}
Handsontable.Dom.addEvent(document.body, 'click', function (e) {
var element = e.target || e.srcElement;
if (element.nodeName == "BUTTON" && element.name == 'dump') {
var name = element.getAttribute('data-dump');
var instance = element.getAttribute('data-instance');
var hot = window[instance];
console.log('data of ' + name, hot.getData());
}
});
}
bindDumpButton();
});