viewer.onInteraction async

Stimulsoft Reports.JS discussion
Post Reply
Vardenis
Posts: 8
Joined: Mon Feb 03, 2020 1:27 pm

viewer.onInteraction async

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: viewer.onInteraction async

Post by HighAley »

Hello,

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

Thank you.

Ticket reference: #1595
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: viewer.onInteraction async

Post 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.
Vardenis
Posts: 8
Joined: Mon Feb 03, 2020 1:27 pm

Re: viewer.onInteraction async

Post 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);
Lech Kulikowski
Posts: 7292
Joined: Tue Mar 20, 2018 5:34 am

Re: viewer.onInteraction async

Post by Lech Kulikowski »

Hello

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

Thank you.
Post Reply