How to refresh viewer

Stimulsoft Reports.JS discussion
Post Reply
jaqb
Posts: 23
Joined: Thu Jul 25, 2024 7:09 am

How to refresh viewer

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

Re: How to refresh viewer

Post by Lech Kulikowski »

Hello,

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

Thank you.
jaqb
Posts: 23
Joined: Thu Jul 25, 2024 7:09 am

Re: How to refresh viewer

Post 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.
Max Shamanov
Posts: 975
Joined: Tue Sep 07, 2021 10:11 am

Re: How to refresh viewer

Post by Max Shamanov »

Hello,

Please send us a sample project that reproduces the issue.

Thank you.
Post Reply