Hi !
I'm trying to display error messages in cell instead of native red-background for unvalid cells. The idear is that when the user gives the focus to the cell, he gets again the wrong entry he wrote to correct it.
It appeared to me impossible to use validator, because as far as validator were executed, I could not get the reason for cells not being valid, and write the appropriate message (am I wrong ?)
I tried to use afterChange event, and td.innerHTML attribute. As I realized the error message were lost at the next call of renderer, I also wrote a custom renderer, assuming that all my error messages would start with "!" (I could not see any simple way to keep in memory that cells are not valid). But I get some crazy behaviour (like error message displaying on the wrong cell when scrolling, etc, etc.
Any idear to get a better way ? Thanks so much for helping.
Ferdinand
afterChange: function(changes, source){
changes && changes.forEach(function (change) {
row = change[0]
col = $("tabName").handsontable('propToCol',change[1])
error = ""
val = change[3]
if ( val !="" )
{
// Get the error message
}
var td = $("tabName").handsontable('getCell', row, col);
if (error != "")
{
td.innerHTML = error
td.style.color = "red"
entry['isValid'] = false // si le champ est invalide, la ligne entière l'est
} else
{
td.innerHTML = change[3]
td.style.color = "black"
}
})
}
var errorRenderer = function (instance, TD, row, col, prop, value, cellProperties, types) {
var isError = TD.innerHTML[0] == '!'
if (!isError)
{
Handsontable.TextCell.renderer.apply(this, arguments);
}
else
TD.style.color = "red"
}