5.6.1 Calculate Page Total
Calculating the page total itself is very simple. First declare two report-level variables in the onLoad Handler, total1 and total2. These will be used to store the totals over 1000 and below 1000 on the current page.
var total1 = 0; // for total over 1000
var total2 = 0; // for total under 1000
Next, add a script to the total field (Text) in the Content band to add the total value to the two total variables, and to display the appropriate highlighting.
// calculate page total and highlight
if(value > 1000) {
total1 += value;
band.background = [0,255,0]; // green
}
else {
total2 += value;
band.background = [255,255,255]; // white
}
Finally, add an onPageBreak Handler script to display the two totals in the footer, and to reset the total variables.
// assign to footer text element
totalOver.text = formatNumber(total1, "$#,##0.00");
totalBelow.text = formatNumber(total2, "$#,##0.00");
// reset totals
total1 = 0;
total2 = 0;
| << 5.6 Report Handler Example | © 1996-2013 InetSoft Technology Corporation (v11.5) | 5.6.2 Band Rewinding >> |