Handsontable example
by Helmut Granda
HTML
<div>
<div id="example1" class="hot handsontable htRowHeaders htColumnHeaders"></div>
</div>
CSS
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="https://docs.handsontable.com/pro/1.3.4/bower_components/handsontable-pro/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/pro/1.3.4/bower_components/handsontable-pro/dist/handsontable.full.min.css">
<style>
.htFiltersMenuLabel, .htUIInput.htUIMultipleSelectSearch{
display:none;
}
</style>
JavaScript
document.addEventListener("DOMContentLoaded", function() {
var dataObj = [
['0V - 24V', '10 kHz', '8', 'Sinking', '$99.00', 23],
['0V - 24V', '10 kHz', '8', 'Sinking', '$99.00', 6],
['0V - 24V', '10 kHz', '8', 'Sinking, Sourcing', '$99.00', 26],
['0V - 250V', '333 kHz', '4', 'Sinking, Sourcing', '$181.00', 98],
['0V - 250V', '333 kHz', '4', 'Sinking, Sourcing', '$181.00', 8.5]
];
var example1 = document.getElementById('example1');
var hot = new Handsontable(example1, {
data: dataObj,
columns: [
{type: 'text'},
{type: 'text'},
{type: 'text'},
{type: 'text'},
{type: 'date', dateFormat: 'M/D/YYYY'},
{type: 'numeric'}
],
colHeaders: true,
rowHeaders: true,
dropdownMenu: true,
dropdownMenu: ['filter_by_value', 'filter_action_bar'],
columnSorting: true,
filters: true
});
window.hot = hot;
function bindDumpButton() {
if (typeof Handsontable === "undefined") {
return;
}
Handsontable.Dom.addEvent(document.body, 'click', function (e) {
var element = e.target || e.srcElement;
if (element.nodeName == "INPUT" && element.className == "htCheckboxRendererInput") {
console.log( window.hot);
window.hot.render();
}
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();
});