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.10.2/bower_components/handsontable-pro/dist/handsontable.full.min.js"></script> <link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/pro/1.10.2/bower_components/handsontable-pro/dist/handsontable.full.min.css"><style>
.handsontable .red {
background: red !important;
}
.handsontable .white {
background: white !important;
}
JavaScript
document.addEventListener("DOMContentLoaded", function() {
var
container = document.getElementById('example1'),
hot;
hot = Handsontable(container, {
data: Handsontable.helper.createSpreadsheetData(10, 20),
currentRowClassName: 'currentRow',
currentColClassName: 'currentCol',
rowHeaders: true,
colHeaders: true,
fixedColumnsLeft: 2
});
var rowBefore = 0;
hot.addHook('afterOnCellMouseOver', function(e, coords, TD) {
if (coords.row >= 0 && coords.col >= 0) {
for (var i = 0; i < hot.countCols(); i++) {
hot.setCellMeta(coords.row, i, 'className', 'red');
hot.render();
}
for (var i = 0; i < hot.countCols(); i++) {
hot.setCellMeta(rowBefore, i, 'className', 'white');
hot.render();
}
}
rowBefore = coords.row;
})
});