InetSoft's Reporting Software: Report Handlers

Previous chapters explained how you can add scripts to various report elements (Tables, Charts, etc.) to modify those elements' properties. These element-level script are executed when the element is processed in the course of report generation.

The current chapter explains how you can use various report handlers to implement advanced business logic. This includes adding actions to report elements, and modifying report generation based on user input or the runtime environment.

View 2-min Demo
Register for Pricing
#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

onClick Handler

An element's onClick handler is executed when a “selection” event (i.e., mouse click) takes place on the element. You can use the onClick handler to implement interactions such as hyperlinks and drilldowns, or to initiate any other business logic in response to user selections.

To access the onClick handler for an element, right-click the element, and select 'Script' from the context menu. Then select the onClick tab at the top of the Script Editor.

Figure 5. The onClick tab of the Script Editor

Using the onClick Handler

Because the handler does not execute on the client browser, it cannot perform client-side actions directly. Instead, the handler controls the behavior of the report by returning one of the pre-defined viewer actions. Actions related to hyperlinks are showReplet() and showURL(). Other viewer actions are discussed in a later chapter.

Note: The viewer action functions (showReplet, sendRequest, etc.) should be the final statement of the onClick script.

The onClick handler is primarily used for Tables and Text elements, in situations where you cannot completely define the hyperlinks at design time. For example, if a hyperlink is required to pass parameters that might change as a result of user interactions, you can compute the parameter values in the onClick handler, and then create the hyperlink by using the showReplet() action.

For example, consider the following onClick script attached to an element. When the user clicks the element, the script tests a condition, and then loads one of two possible reports.

if(condition) {
   showReplet("order info",[["start_date",CALC.today()]]);
}
else {
   showReplet("customer info",[["state", "NJ"]]);
}
Previous: Query Compatibility Next: Setting the onClick Range