To build a loaded report, you should call the render() function on the report object. For example, you want to build a report before exporting it.

 

index.php

 

<?php

$report = new \Stimulsoft\Report\StiReport();

$report->loadFile('SimpleList.mrt');

$report->render();

$report->exportDocument(\Stimulsoft\StiExportFormat::Pdf);

$report->renderHtml();

?>

 

 

 

If you need to perform any actions after rendering a report using JavaScript code, you should pass the name of the JavaScript function as a parameter. For example, after building a report, you need to display the following message:

 

index.php

 

<?php

$report = new \Stimulsoft\Report\StiReport();

$report->loadFile('SimpleList.mrt');

$report->render('onAfterRender');

$report->renderHtml();

?>

 

function onAfterRender() {

alert("The report rendering is completed.");

}

 

 

 

If you need to perform any actions with the report before it is built using JavaScript code, you should specify the name of the JavaScript function for the onBeforeRender event. The action type, and the report itself will be passed in the function arguments. For example, before building a report, you need to register JSON data:

 

index.php

 

<?php

$report = new \Stimulsoft\Report\StiReport();

$report->onBeforeRender = 'onBeforeRender';

$report->render();

$report->renderHtml();

?>

 

function onBeforeRender(args) {

var dataSet = new Stimulsoft.System.Data.DataSet("SimpleDataSet");

dataSet.readJsonFile("Demo.json");

 

var report = args.report;

report.regData(dataSet.dataSetName, "", dataSet);

}