Page 1 of 1

viewer.onInteraction async

Posted: Mon Feb 03, 2020 1:42 pm
by Vardenis
Hello,

I'm trying to get async data within onInteraction function by variables, but if data comes a little bit too late, the report won't show it and the async things actually doesn't help.
Not sure what is happening under the hood, but if I'm not setting slower internet it gets data in time and shows correctly, but if I slow down the internet even a bit it doesn't get it in time and the regData() and synchronize() functions won't do anything for me.

The code looks something like this

Code: Select all

	viewer.onInteraction = async (args) => {

                if (args.action == "Variables") {               
                     
                    await this.httpService.getData("whateverlink").toPromise().then((result) => {

                        const dataSet = new Stimulsoft.System.Data.DataSet();
                        dataSet.readJson(result.data);

                        report.regData("data", "data", dataSet);
                        report.dictionary.synchronize();
                    })
                }
            }
I've also tried function args.async = true, but then I'm not quite sure how to end async method, cause it starts showing spinner on the beginning and it never ends.

P.S. I'm using Angular, but it shouldn't be the reason

Re: viewer.onInteraction async

Posted: Fri Feb 07, 2020 8:49 am
by HighAley
Hello,

We understand your request.
We need more time to prepare an answer for you.

Thank you.

Ticket reference: #1595

Re: viewer.onInteraction async

Posted: Wed Feb 12, 2020 1:49 pm
by HighAley
Hello,

Please, try to use code like this:

Code: Select all

 viewer.onInteraction = async (args, callback) => {
            if (args.action == "Variables") {               
                args.async = true;
                await this.httpService.getData("whateverlink").toPromise().then((result) => {

                    const dataSet = new Stimulsoft.System.Data.DataSet();
                    dataSet.readJson(result.data);

                    report.regData("data", "data", dataSet);
                    report.dictionary.synchronize();

                    callback();
                })
            }
        }
Thank you.

Re: viewer.onInteraction async

Posted: Thu Feb 13, 2020 11:39 am
by Vardenis
Hello,

Thanks! That did the job

Also I had to add args into callback method to pass them back

Code: Select all

callback(args);

Re: viewer.onInteraction async

Posted: Fri Feb 14, 2020 3:08 pm
by Lech Kulikowski
Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.