Stop validation after a change and invoke it on button click

Tags: #<Tag:0x00007f8b1d8b9908> #<Tag:0x00007f8b1d8b9728>

Hi,
I’m working on a project in which I would need to just validate the data after clicking a specific button. I’ve created the column validators as below (just an example):

hotSettings: Handsontable.GridSettings = {
    ...
    columns: [
          {data: 'status', renderer: "html"},
          {data: 'testCode'},
          {data: 'name'},
          {
            data: 'preferredCode',
            validator: (value, callback) => {
              if (value === '') {
                callback(false)
              } else {
                callback(true)
              }
            }
          }
    ]
    ...
}

Those validators are invoked after any change is made in the grid. Is it possible to avoid these validations and just invoke the validators after clicking a button?

I could do it using the validateCells() function, however, I would need to avoid the native validation after the change.

  • Handsontable version: 12.3.1
  • Angular 14

Hi @darupe22

If I understood your requirement correctly you should be able to do this using our afterChange() hook:

Hi @adrian.szymanski ,
Thanks for your reply.

I can not see any parameter/function in the afterChange() hook that avoids the validators to be invoked. Am I missing something?

The aim is to just validate after clicking and not after every change.

Hi @darupe22

It’s tricky to achieve that out of the box, as validation is fired with each editor open action. However, I came up with this workaround: https://jsfiddle.net/aszymanski/8cjrnt36/

Let me know if that meets your requirement.

Hi @adrian.szymanski,
Thanks for your reply and the workaround provided. Unfortunately, that does not resolve my issue, as any change in any other cell will remove the validator. Anyways, I’ll continue working on it.

I think it would be a good feature in the future.

Thanks

Hi @darupe22

I understand. It’s hard to achieve it easily at the moment because of the current table rendering process. We have plans to change in the future so only currently edited cell will be re-rendered.