I am using comments as a explanation to validation failures - if cell is invalid, comment shows the reason why. Also, it is important, that validation is done externally, so HOT validator only marks the cells status and do no real validation.
I am setting and clearing out cell comments in validation function. However, comments are not properly cleared out
http://jsfiddle.net/j6uo7mdq/17/
I have to manually rerender table in order for comments to disapear which is a bug imo.
var globalValid=true;
function validatorFn(value,pushResult){
let isValid=globalValid;
if(!isValid){
this.comments=true;
this.comment={
readOnly: true,
value: "required bro!"
}
}else{
this.comments=false;
this.comment=null;
}
pushResult(isValid);
}
function revalidate(rerender){
globalValid=!globalValid;
snapshot=hot.getData();
hot.validateCells(valid=>{
if(rerender) hot.render();
});
}
var data = function () {
return Handsontable.helper.createSpreadsheetData(5, 5);
};
var container = document.getElementById('example');
var hot = new Handsontable(container, {
data: data(),
minSpareCols: 1,
minSpareRows: 1,
rowHeaders: true,
colHeaders: true,
contextMenu: true,
comments: true,
validator:validatorFn,
cells:(row, column)=>{
if(row==0){
return {
disableVisualSelection: true,
}
}
return {};
}
});