Page 1 of 1

How to refresh viewer

Posted: Wed Oct 23, 2024 11:28 am
by jaqb
Hello, how can I refresh the viewer object after changing the report? I am trying to implement the funcionality for changing reports with dropdown.

When I try to change report when another one is loaded, the data from data source is not setted on the report template and there is thrown exception:
Cannot read properties of null (reading 'pageNumbers')
Here is the pseudocode:

Code: Select all

window["viewer"] = new Stimulsoft.Viewer.StiViewer(null, "StiViewer", false);
...
const reportContent = getReportForSelectedItem();
const report = new Stimulsoft.Report.StiReport();
report.load(reportContent);

//not working
window["viewer"].report = report;

However if I will create a new instance of report viewer, the problem is solved:

Code: Select all

window["viewer"] = new Stimulsoft.Viewer.StiViewer(null, "StiViewer", false);
...
const reportContent = getReportForSelectedItem();
const report = new Stimulsoft.Report.StiReport();
report.load(reportContent);

//working
window["viewer"] = new Stimulsoft.Viewer.StiViewer(null, "StiViewer", false);
window["viewer"].report = report;
I tried to use 'window["viewer"].refreshViewer()' function, but it throws:
Cannot read properties of undefined (reading 'postAction')
Is there a possibility to refresh existing viewer instance? I would like to avoid create new instance of the viewer.

Re: How to refresh viewer

Posted: Wed Oct 23, 2024 9:03 pm
by Lech Kulikowski
Hello,

Try to call the Refresh action:
jsStiWebViewer1.postAction("Refresh");

Thank you.

Re: How to refresh viewer

Posted: Thu Oct 24, 2024 7:20 am
by jaqb
Viewer object does not have 'postAction()' method but it has 'jsObject' property with this method so I call 'window["viewer"].jsObject.postAction("Refresh")'. Unfortunately it has no effect - still throws exception 'Cannot read properties of null (reading 'pageNumbers')' and not render correctly.

Re: How to refresh viewer

Posted: Thu Oct 24, 2024 3:20 pm
by Max Shamanov
Hello,

Please send us a sample project that reproduces the issue.

Thank you.