How to get the reference to the table in a hooks callback

Tags: #<Tag:0x00007efc60218898>

I wonder what is the common approach to call a function on the table instance as a reaction on a user interaction, aka hook.
Right now I solved it like this:

let table = {};

Handsontable.hooks.add("afterChange", function (changes) {
   table.doSomething()
});

table = new Handsontable(container1, {
  data,
  formulas: {
    engine
  },
  licenseKey: "non-commercial-and-evaluation"
});

Hi @koeberle

yes, that’s what should be done. The table variable holds the reference to the instance of Handsontable. Then you can use all the Core method listed here https://handsontable.com/docs/9.0.0/Core.html

When you want to access a plugin method you should use the table.getPlugin('name_of_plugin') and then the plugin method.

1 Like