Report Rendering
To build a loaded report, you need to call the render() function on the StiReport report object. For example, you need to build a report before exporting it:
app.py |
from stimulsoft_reports.report import StiReport from stimulsoft_reports.report.enums import StiExportFormat
report = StiReport() report.loadFile(url_for('static', filename='reports/SimpleList.mrt')) report.render() report.exportDocument(StiExportFormat.PDF)
|
If you need to perform any actions after building a report using JavaScript code, simply utilize the onAfterRender event on the report object. More details about this are provided in the Reporting tool engine. For instance, after building a report, you may need to display the following message:
app.py |
from stimulsoft_reports.report import StiReport
report = StiReport() report.onAfterRender += 'afterRender' report.loadFile(url_for('static', filename='reports/SimpleList.mrt')) report.render()
|
render.html |
<script> function afterRender(args) { alert("The report rendering is completed."); } </script>
|
If you need to perform any actions with the report before building it using JavaScript code, just use the onBeforeRender event on the report object. For example, before rendering a report, you need to register JSON data:
app.py |
from stimulsoft_reports.report import StiReport
report = StiReport() report.onBeforeRender += 'beforeRender' report.loadFile(url_for('static', filename='reports/SimpleList.mrt')) report.render()
|
render.html |
<script> function onBeforeRender(args) { var dataSet = new Stimulsoft.System.Data.DataSet("SimpleDataSet"); dataSet.readJsonFile("Demo.json");
var report = args.report; report.regData(dataSet.dataSetName, "", dataSet); } </script>
|