Handsontable example
by handsoncode
HTML
<p>
<input type="checkbox" class="move"> Allow moving
</p>
<div id="example"></div>
<script src="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.css">
JavaScript
const example = document.getElementById('example');
let allowMove = false;
const hot = new Handsontable(example, {
data: Handsontable.helper.createSpreadsheetData(200, 20),
licenseKey: 'non-commercial-and-evaluation',
colHeaders: true,
colWidths: 100,
manualColumnMove: true,
beforeColumnMove() {
return allowMove;
},
});
document.querySelector('.move').addEventListener('change', function(event){
allowMove = event.target.checked;
});
hot.render();