Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically add "comment" during validation in Handsontable

Tags:

handsontable

I can see that there are ways of creating comments in the cells array before rendering, and using the context menu. But is there a way to create a comment after a change?

I originally tried this:

var errors = [];

var hot = new Handsontable(container, {
    data: vendors,
    startRows: 1,
    afterChange: function(changes, source) {
        var row = changes[0][0];
        var col = changes[0][1];
        errors.push({
            row: row,
            col: col,
            comment: "Error"
        })
    comments: errors
}

But it seems as though changing the errors object doesn't automatically render the comments. Is there a better way?

like image 932
ZekeDroid Avatar asked Nov 19 '25 03:11

ZekeDroid


1 Answers

Comment can be added on meta object as follows

var hot = new Handsontable(container, {
    data: vendors,
    startRows: 1,
    afterChange: function(changes, source) {
        var row = changes[0][0];
        var col = changes[0][1];
        hot.getCellMeta(row, col).comment =  'Error';
   }
}
like image 123
Ramu Avatar answered Nov 22 '25 04:11

Ramu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!