Viewer Events
The report viewer supports events that provide the ability to perform necessary operations before specific actions—both on the JavaScript client side and the Python server side. A detailed description of how events work can be found in the Report Engine Events section.
Some event arguments take values from enumerations that are located in specific namespaces. All the enumerations used in designer events are listed in the code block below:
app.py |
from stimulsoft_reports.enums import StiEventType from stimulsoft_reports.report.enums import StiExportFormat from stimulsoft_reports.viewer.enums import StiPrintAction, StiExportAction
|
viewer.html |
<script> StiExportAction = Stimulsoft.Viewer.StiExportAction; StiExportFormat = Stimulsoft.Report.StiExportFormat; </script>
|
The viewer supports the following events:
[v] JavaScript [v] Python
The event is triggered before the report is built, after the report variables are prepared. A list of event arguments can be found in the Report Engine Events section. Detailed descriptions and usage examples can be found in the Working with Report Variables section.
[v] JavaScript [v] Python
The event is triggered before requesting the data needed to build the report. A list of event arguments can be found in the Report Engine Events section. Detailed descriptions and usage examples can be found in the Connecting Data Files and Connecting SQL Data Adapters sections.
[v] JavaScript [v] Python
The event is triggered after the data is loaded, before the report is built. A list of event arguments can be found in the "Report Engine Events" section. Detailed descriptions and usage examples can be found in the Connecting Data Files and Connecting SQL Data Adapters sections.
onOpenReport
[v] JavaScript [x] Python
The event is triggered before opening the report after the toolbar button is clicked.
List of properties passed in the event arguments on the JavaScript client-side:
Name |
Description |
||||
event |
The identifier of the current event has the value "OpenReport". |
||||
sender |
The identifier of the component that initiated this event can take the following value:
|
||||
report |
The current report object will be passed as null in the arguments of this event. |
||||
preventDefault |
This flag allows you to stop further event handling by the viewer. By default, it is set to false. |
onOpenedReport
[v] JavaScript [v] Python
The event is triggered after opening a report from the designer menu but before it is loaded into the viewer.
List of properties passed in the event arguments on the JavaScript client-side:
Name |
Description |
||||
event |
The identifier of the current event, with the value "OpenedReport". |
||||
sender |
The identifier of the component that initiated the event, which can have the following value:
|
||||
report |
The current report object. |
||||
preventDefault |
This flag allows you to stop further event processing by the designer. By default, it is set to false. |
List of properties passed in the event arguments on the Python server side. The arguments are of type StiReportEventArgs:
Name |
Description |
||||
event |
The identifier of the current event, for this event the value is StiEventType.OPENED_REPORT |
||||
sender |
The identifier of the component that initiated the event, which can take the following value:
|
||||
report |
The current report object in the form of a JSON string or object. |
[v] JavaScript [v] Python
The event is triggered before printing the report. The table below shows the list of event handler arguments on the client-side in JavaScript:
Name |
Description |
||||||
event |
The identifier of the current event, with the value "PrintReport". |
||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||
report |
The current report object. |
||||||
printAction |
The type of report printing. Possible values:
|
||||||
preventDefault |
This flag allows you to stop further event handling by the viewer. By default, it is set to false. |
The list of properties passed as event arguments on the server side in Python has the type StiReportEventArgs:
Name |
Description |
||||||
event |
The identifier of the current event, has the StiEventType.PRINT_REPORT. |
||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||
report |
The current report object. |
||||||
printAction |
The type of report printing. Possible values:
|
For detailed descriptions and usage examples, refer to the Report Printing section.
[v] JavaScript [v] Python
The event is triggered before exporting the report, after the export settings dialog. The table below shows the list of event handler arguments on the client-side in JavaScript:
Name |
Description |
||||||||||||||||||||||||||
event |
The identifier of the current event, has the value "BeginExportReport". |
||||||||||||||||||||||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||||||||||||||||||||||
report |
The current report object. |
||||||||||||||||||||||||||
action |
The action that triggered the export event, possible values:
|
||||||||||||||||||||||||||
format |
The selected report export format, possible values:
|
||||||||||||||||||||||||||
formatName |
The name of the selected export format, corresponds to the format enumeration constants. |
||||||||||||||||||||||||||
settings |
The settings of the selected export format. The available properties list will depend on the chosen export type. |
||||||||||||||||||||||||||
fileName |
The report file name to save after export completion. |
||||||||||||||||||||||||||
openAfterExport |
A flag indicating whether the report will be exported in a new browser tab (`true`), or if the file save dialog will be prompted after the export (`false`). |
||||||||||||||||||||||||||
preventDefault |
This flag allows you to stop further event handling by the viewer. By default, it is set to false. |
The list of properties passed as event arguments on the server side in Python has the type StiExportEventArgs:
Name |
Description |
||||||||||||||||||||||||||
event |
The identifier of the current event, has the value StiEventType.BEGIN_EXPORT_REPORT. |
||||||||||||||||||||||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||||||||||||||||||||||
report |
The current report object. |
||||||||||||||||||||||||||
action |
The action that triggered the export event, possible values:
|
||||||||||||||||||||||||||
format |
The selected report export format, possible values:
|
||||||||||||||||||||||||||
formatName |
The name of the selected export format, corresponds to the format enumeration constants. |
||||||||||||||||||||||||||
settings |
The settings of the selected export format. The available properties list will depend on the chosen export type. |
||||||||||||||||||||||||||
fileName |
The report file name to save after export completion. |
||||||||||||||||||||||||||
openAfterExport |
A flag indicating whether the report will be exported in a new browser tab (`true`), or if the file save dialog will be prompted after the export (`false`). |
[v] JavaScript [v] Python
The event is triggered after the report has been exported, but before it is saved as a file. The table below shows the list of event handler arguments on the client-side in JavaScript:
Name |
Description |
||||||||||||||||||||||||||
event |
The identifier of the current event, has the value "EndExportReport". |
||||||||||||||||||||||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||||||||||||||||||||||
report |
The current report object. |
||||||||||||||||||||||||||
format |
The selected report export format, possible values:
|
||||||||||||||||||||||||||
formatName |
The name of the selected export format, corresponds to the format enumeration constants. |
||||||||||||||||||||||||||
data |
The byte data of the exported report, prepared for saving to a file. |
||||||||||||||||||||||||||
fileName |
The report file name to save after export completion. |
||||||||||||||||||||||||||
openAfterExport |
A flag indicating whether the report will be exported in a new browser tab (`true`), or if the file save dialog will be prompted after the export (`false`). |
||||||||||||||||||||||||||
preventDefault |
This flag allows you to stop further event handling by the viewer. By default, it is set to false. |
The list of properties passed as event arguments on the server side in Python has the type StiExportEventArgs:
Name |
Description |
||||||||||||||||||||||||||
event |
The identifier of the current event, has the value StiEventType.END_EXPORT_REPORT. |
||||||||||||||||||||||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||||||||||||||||||||||
format |
The selected report export format, possible values:
|
||||||||||||||||||||||||||
formatName |
The name of the selected export format, corresponds to the format enumeration constants. |
||||||||||||||||||||||||||
data |
The byte data of the exported report, prepared for saving to a file. |
||||||||||||||||||||||||||
fileName |
The report file name to save after export completion. |
||||||||||||||||||||||||||
fileExtension |
The file extension for the report to save after export completion, corresponds to the selected format type. |
||||||||||||||||||||||||||
mimeType |
The MIME type for the selected export format. |
||||||||||||||||||||||||||
openAfterExport |
A flag indicating whether the report will be exported in a new browser tab (`true`), or if the file save dialog will be prompted after the export (`false`). |
[v] JavaScript [x] Python
The event is triggered at the moment of an interactive action in the viewer (dynamic sorting, collapsing, drill-down, applying parameters) before the report generator processes the values. The table below shows the list of event handler arguments on the client-side in JavaScript:
Name |
Description |
||||||||||||||||||||
event |
The identifier of the current event, has the value "Interaction". |
||||||||||||||||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||||||||||||||||
report |
The current report object. |
||||||||||||||||||||
action |
The identifier of the current interactive action, possible values:
|
||||||||||||||||||||
variables |
A collection of report variables and their values, set on the parameters panel.. |
||||||||||||||||||||
sortingParameters |
A collection of parameters required for dynamic report sorting. |
||||||||||||||||||||
collapsingParameters |
A collection of parameters required for dynamic collapsing of report elements. |
||||||||||||||||||||
drillDownParameters |
A collection of parameters required for report drill-down. |
||||||||||||||||||||
filteringParameters |
A collection of parameters required for sorting, filtering, and drill-down in dashboard elements. |
||||||||||||||||||||
preventDefault |
This flag allows stopping further event handling. By default, it is set to false. |
[v] JavaScript [v] Python
The event is triggered after the report is exported and before it is sent via Email. The table below lists the event handler arguments on the client side in JavaScript:
Name |
Description |
||||||||||||||||||||||||||
event |
The identifier of the current event, has the value "EmailReport". |
||||||||||||||||||||||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||||||||||||||||||||||
report |
The current report object. |
||||||||||||||||||||||||||
format |
The selected report export format, possible values:
|
||||||||||||||||||||||||||
formatName |
The name of the selected report export format, corresponding to the format enum constants. |
||||||||||||||||||||||||||
data |
The byte data of the exported report, prepared for sending via Email. |
||||||||||||||||||||||||||
fileName |
The name of the report file for sending by Email. |
||||||||||||||||||||||||||
settings |
An object containing the parameters filled in the viewer's Email sending dialog. |
The table below shows the list of Email sending parameters on the client-side in JavaScript.
Name |
Description |
settings.email |
The Email address to which the exported report will be sent. |
settings.subject |
The subject of the email. |
settings.message |
The text of the email. |
List of properties passed in the event arguments on the Python server-side. The arguments are of type StiExportEventArgs:
Name |
Description |
||||||||||||||||||||||||||
event |
The identifier of the current event, for this event it is StiEventType.EMAIL_REPORT. |
||||||||||||||||||||||||||
sender |
The identifier of the component that triggered this event, possible values:
|
||||||||||||||||||||||||||
report |
The current report object in JSON format. |
||||||||||||||||||||||||||
format |
The selected report export format, possible values:
|
||||||||||||||||||||||||||
formatName |
The name of the selected report export format, matching the enum constants. |
||||||||||||||||||||||||||
data |
The byte data of the exported report, prepared for sending via Email. |
||||||||||||||||||||||||||
fileName |
The name of the report file for sending by Email. |
||||||||||||||||||||||||||
settings |
An object containing the Email sending parameters on the server-side. |
List of Email sending parameters on the Python server-side. All settings are in the StiEmailSettings class:
Name |
Description |
fromAddr |
The email address of the sender. |
name |
The full name of the sender. |
toAddr |
The email address to which the exported report will be sent (from the viewer's dialog). |
subject |
The email subject (from the viewer's dialog). |
message |
The email text (from the viewer's dialog). |
attachmentName |
The name of the report file in the attachment (default: report file name). |
charset |
The character encoding used for the email body (default: "UTF-8"). |
host |
The SMTP server address (required). |
port |
The SMTP server port (default: 465). |
login |
The login for the email server (required). |
password |
The password for the email server (required). |
secure |
The type of encryption for the email connection (`ssl` or tls, default: `ssl`). |
cc |
An array of CC (Carbon Copy) addresses for secondary recipients. |
bcc |
An array of BCC (Blind Carbon Copy) addresses for hidden recipients. |
[v] JavaScript [x] Python
The event is triggered when the Design button on the viewer panel is clicked. The table below lists the event handler arguments on the client side in JavaScript:
Name |
Description |
||
event |
The identifier of the current event, with the value "DesignReport". |
||
sender |
The identifier of the component that triggered the event, possible value:
|
||
report |
The current report object. |
||
fileName |
The name of the report file to be passed and loaded into the designer. |