How to trigger afterchange event manually?

Tags: #<Tag:0x00007efc64e01020>

How to trigger afterchange event manually?
Like from another method.

Hi @aswram23

afterChange() is triggered after each change of content via edit, autofill, paste, etc. As I assume you have some custom logic you’d want to run in a certain moment when a user does not change the cell value. Am I right?

Hi @aleksandra_budnik
Yes exactly. i want to call afterchange event from a method when user doesnt change anything.

Regenerally, it would be better to pack your custom logic of the afterChange() hook into a function and reuse it in those two places, like

function customFunction(){
alert('test')
}

const container = document.querySelector('#example1');
const hot = new Handsontable(container, {
  data: [],
  afterChange: function(){	
  	customFunction()
  }
});

function Xyz(){
	customFunction()
}

But if that won’t work in your case you can do a simple cell edition that does not change the value. Example

let myVal = hot.getDataAtCell(0,0);
hot.setDataAtCell(0,0, 'myVal`);
1 Like