Hello,
We have a dashboard in which we load several pivot tables. It's clear that the 'reportcomplete' event is triggered when a table has been loaded an rendered. However, when we're loading the dashboard, there are tables that render faster than others, so when one is rendered, the 'reportcomplete' event is triggered and causes errors because other tables haven't been loaded. Is there a way to call a function when all 'reportcomplete's in the dashboard have been triggered?
Thank you!
Hello Bernat,
Thank you for your question. Here is a couple of solutions you can choose from:
reportcomplete
dispatchers. As soon as that number equals the number of pivots, you can be sure that everything is successfully loaded.reportcomplete
event. Please see the following JSFiddle example: https://jsfiddle.net/flexmonster/npsz5rck/149/. Each handler calls the same method and passes an appropriate Flexmonster object. In such a way, you can be sure that you are working with the up and running Flexmonster instance.Please let us know if the information above helped to resolve the case.
Regards,
Dmytro
Hi Dmytro,
Your second approach fits perfectly with what we need to do. However, you set the pivot table as a variable in the same code, so you can call the object with "pivot1." but we can't because the table is already set in our server. We use the 'reportcomplete' event like this:
flexmonster.on ( 'reportcomplete', function ( event ){ code });
How can we get which table has triggered the event?
Kind regards,
Bernat Pinós
By the way, is there a way to count how many rows a table has from JavaScript (with jQuery)?
Hello Bernat,
Thank you for your feedback.
Each Flexmonster instance is separated from one another. The flexmonster
reference which is stored in DOM has access only to the last created instance. Therefore, if you work with multiple Flexmonster instances on the page you need to take care of storing the references on your own. In such case, when multiple objects are created each of them should be stored in a separate variable.
As for counting table rows, it is not possible to achieve using jQuery and DOM since Flexmonster has a virtual grid and it does not render all the view at once. Currently, there is no API call which allows getting the number of rows.
Please let us know in case of any other question.
Regards,
Dmytro