Opening the Report in the Viewer and Changing it on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.Handle onOpenedReport in the PHP viewer to modify a report before it reaches the browser.
Viewer setup. Configure the viewer, load the report, assign it to the component, and process the requests or events raised by the UI.
The event lets you inspect and replace the report on the server — here it changes a property and swaps in a different template — before the viewer displays it to the user.
Viewer setup. Configure the viewer, load the report, assign it to the component, and process the requests or events raised by the UI.
$viewer->onOpenedReport = function (StiReportEventArgs $args) {
$args->report->ReportAlias = 'Report Alias from Server-Side';
$reportJsonString = file_get_contents('../reports/SimpleList.mrt');
$args->setReportJson($reportJsonString);
};
$viewer->process();onOpenedReport— fires on the server when a report is opened in the viewer, before it is shown.$args->report->ReportAlias— modifies a property of the opened report.$args->setReportJson(...)— replaces the opened report with a different template read from disk.
The event lets you inspect and replace the report on the server — here it changes a property and swaps in a different template — before the viewer displays it to the user.