How to "process" pasted data using Async function

Tags: #<Tag:0x00007efc60c54d48> #<Tag:0x00007efc60c54c08>

Hi,

I have a case where users paste data into Handsontable.
But the pasted data has to be “processed” using an async function. How can I do that?

My problems:

  • I used async function in beforePaste - no success as the other hooks (beforeChange, …, afterChange) are triggered before the async function returns the result

    • I also tried to call async function in beforeChange - same result.
  • I can use afterChange or afterPaste hook to “process” the data, but that means I’m actually setting cell value twice

    • first time - when user pasted data
    • second time - when async function returns the result (processed data)
    • That also means that the UndoRedo stack is not correct (as there are two changes there instead of only one)

So, is there any chance to “process” pasted data using async function in any “before***” hook?

Thanks,
Andraz

Hi @andraz.podobnik

Can you please share you current implementation in a code demo? I’ve seen that our users implemented async functions within before hooks previously.

I prepared an example where I’m trying to “process/modify” the pasted data in the beforePaste hook (calling async function).

https://jsfiddle.net/xmza6dqt/4/

Andraz

Hi again,

you can close this thread - I found a way to do this.
In beforePaste I simply call another function within which I then use “setDataAtCell”.

Thanks,
Andraz

Hi @andraz.podobnik

Thank you for the update, I’m glad that you’ve found the solution.

I’m sorry I didn’t respond after you send the example, but we don’t get notifications if someone edit their message, so it’s always better to post in new message.