The 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;

}

<< The OnPageBreak Event Handler © 1996-2013 InetSoft Technology Corporation (v11.4) 5.5 onPrint Handler >>