Handsontable example
by Lena Coudeville
HTML
<div id="example1" class="hot handsontable"></div>
CSS
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="https://docs.handsontable.com/0.15.1/scripts/jquery.min.js"></script>
<script src="https://docs.handsontable.com/0.15.1/bower_components/handsontable/dist/handsontable.full.js"></script>
<link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/0.15.1/bower_components/handsontable/dist/handsontable.full.min.css">
JavaScript
document.addEventListener("DOMContentLoaded", function() {
var
container = document.getElementById("example1"),
hot;
hot = new Handsontable(container, {
data: [
['A', 'B', 'C'],
['A', '', ''],
['', '', '']
],
colHeaders: true,
columns: [
{
editor: 'select',
selectOptions: ['A', 'B']},
{
editor: 'select',
selectOptions: ['B', 'C', 'D']
},
{
editor: 'select',
selectOptions: ['C', 'D']
}
]
});
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();
});