InetSoft Product Information: Banded Reports - Rewound Property

The “rewound” property has special significance in Section scripting. When a Section is printed on a page, the bands are repeated for each row of the table. If a band goes outside of the boundary of the page, the band is “rewound” and printed on the next page.

Normally this does not cause a problem, because when the band is rewound, it does not re-execute any associated scripts. The only time this is an issue is when the calculation of elements in a band is used in the page header and footer. For example, if a script is attached to an element in the band for calculating a running total on the page, the total would contain an extra value from the next page.

To correct this problem, you need to handle rewinding for scripts in the onPageBreak handler. First, check if the rewound property is set. If it is, the script undoes the effect of the previous script and pushes the value to the next page.

// assume the band script saves the last value added to the total
// in a report variable 'lastValue'

if(event.rewound) {
   // assume total is the report variable used to hold the page total
   total -= lastValue;
}

// Text1 is the text element on footer for displaying the page total
Text1.text = total;
 
// reset page total for next page
if(event.rewound) {
   total = lastValue;
}
else {
   total = 0;
}

dashboard demo
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software.

onPrint Handler

The onPrint handler is executed before a report is printed or exported. The typical usages of onPrint handlers are as follows:

Note: The best way to do this is to set 'Hide on Print and Export'. See Property Dialog Boxes in the Report Designer for details.

• Hiding non-printable elements.

• Including a title page in a report

• Performing logic specific to printing and exporting.

The onPrint event handler offers a special property, 'report.format', through the 'docInfo' object.

docInfo['report.format'] 

When the user exports a report to a specific format, this property holds the file extension of the specified format (e.g., xls, html, rtf, txt, etc.) This allows you to implement different logic based on the selected export format.

Report Handler Example

In this example (handlers.srt in the examples/docExamples/script directory) you will use report-level scripts to calculate the per-page total of sales over and below $1,000. It uses handlers to perform the following tasks:

Note: Set your Registry location to examples/docExamples/script. See Registry Configuration in Report Designer for instructions.

• In the page footer, display the sales totals for the current page over and below $1,000.

• Highlight the rows with sales over $1,000.



Figure 6. Report Handler Example (handlers.srt)
executive dashboard
Read why choosing InetSoft's cloud-flexible BI provides advantages over other BI options.