Handsontable example
by Aleksandra Maria Budnik
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable-pro@6.2.2/dist/handsontable.full.min.css">
<script src="https://cdn.jsdelivr.net/npm/handsontable-pro@6.2.2/dist/handsontable.full.min.js"></script>
<div id="example1"></div>
<div class="window">
<h2>My window</h2>
Change the value <input type="text" class="add">
<button class="hide">Confirm</button>
</div>
CSS
.window {
position: absolute;
width: 300px;
background: #fff;
border: 1px solid #cecece;
visibility: hidden;
top: 0;
left: 0;
padding: 50px;
margin: 40px;
box-shadow: 0px 0px 42px 11px #eee;
z-index: 140
}
.hide {
background: #85ce6d;
border: 0;
font-size: 18px;
padding: 7px;
margin-top: 1em;
width: 120px;
color: #fff;
box-shadow: 0;
float: right;
border-radius: 2px;
}
JavaScript
var data = [
[1, 2, 3, 5],
[8, 9, 5, 6]
],
container = document.getElementById('example1'),
hot;
var win = document.querySelector('.window');
var row, col;
hot = new Handsontable(container, {
data: data,
rowHeaders: true,
colHeaders: true,
outsideClickDeselects: false,
afterBeginEditing: function(row, col) {
console.log(row, col);
win.style.visibility = 'visible';
row = hot.getSelectedLast()[0];
col = hot.getSelectedLast()[1];
}
});
document.querySelector('.hide').addEventListener('click', function() {
let row = hot.getSelected()[0][0];
let col = hot.getSelected()[0][1];
console.log(row, col)
var myValue = document.querySelector('.add').value;
hot.setDataAtCell(row, col, myValue);
win.style.visibility = 'hidden'
})