Handsontable example
by aszymanski
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@12.3.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@12.3.1/dist/handsontable.full.min.css" />
<div id="example1" class="hot "></div>
<br>
<button class="btn">Validate</button>
JavaScript
const container = document.querySelector('#example1');
const customValidator = (value, callback) => {
if (value === '') {
callback(false)
} else {
callback(true)
}
}
const hot = new Handsontable(container, {
data: [
[5, 2, 63, 8]
],
colHeaders: true,
licenseKey: 'non-commercial-and-evaluation',
columns: [{}, {}, {}, {
validator: customValidator
}],
afterChange: (changes) => {
if (changes) {
hot.updateSettings({
columns: [{}, {}, {}, {
validator: null
}]
})
}
}
});
document.querySelector('.btn').addEventListener('click', function() {
hot.updateSettings({
columns: [{}, {}, {}, {
validator: customValidator
}]
})
hot.validateCells()
})