Menu
Download Free Trial

How do I load a report from the server on window.onload?

Answered

Once the HTML page has finished loading I need to load a server report. I have tried performing the load after the embedPivotComponent method and this does not work.
 flexmonster.embedPivotComponent(“/flexmonster/”, “pivotContainer”, “100%”, “615”, config, true);
 flexmonster.load(‘myurl/myreport.xml’);
 
I have also tried trapping window.onload = and even went through a conditioning sequence to insure the flexgrids onload calls occur first
 
var oldOnLoad = window.onload;
    // if there is not any function hooked to it
    if (typeof window.onload != 'function') {
        // you can hook your function with it
        window.onload = func
    } else { // someone already hooked a function
        window.onload = function () {
            // call the function hooked already
            oldOnLoad();
            // call your awesome function
            func();
        }
    }
 
There appears to be no configuration property to enable this. My reason for the post onload call is that I’m building an application that allows the user to embed the report name in the URL. For example: myserver/report.html?reportid=myreport
 
I have server-side code that splits out the myreport value from the URI and makes it available to the JavaScript. The problem is invoking the flexmonster.load(‘url’); once the page is done loading. Is this really an uncommon workflow?
 
Thanks,
Jeremy
 

2 answers

Public
Roman Petrusha Flexmonster March 24, 2016

Hi!

Yes, I understand your problem. You can’t use window.onload event because the component requires more time for initialization. It’s still loading libs and resources after onload event fired. I recommend you to use jsPivotCreationCompleteHandler in this case. E.g.
var pivot = flexmonster.embedPivotComponent(“”, “pivotContainer”, “100%”, “600”,
{
  jsPivotCreationCompleteHandler: onCreationComplete
}, true);
function onCreationComplete() {
   flexmonster.load(‘myurl/myreport.xml’);
}
Does it work for you?

Public
Tanya Gryshko Flexmonster December 5, 2016

Hello Jeremy and all Flexmonster users,
In version 2.3 jsPivotCreationCompleteHandler was replaced with reportcomplete event. In the previous version embedPivotComponent() function was used to embed the component. In the version 2.3 it was removed, but it will be supported in this version in terms of backward compatibility. Instead of embedPivotComponent() you should use a jQuery call. Please read our guide for migration from the previous major version to 2.3.
Regards,
Tanya

Please login or Register to Submit Answer