События

Top  Previous  Next

In order to control the report with maximum flexibility, every report object has got several events. For example, in a handler, connected to the "Data" band, you can filter records, that is, hide or show the band depending on certain conditions.

 

Let us consider the events which are fired during the report generation process. As an example, we will take a simple report, containing one page, one "Data" band and two "Text" objects on the band:

 

scriptEvents1

 

In the beginning of the report, the "Report" object fires the StartReport event. Before formation of the report page, the StartPage event is fired. This event is fired once for every template page (do not confuse with prepared report page!). In our case, regardless of how many pages were in the prepared report - event is fired once, since the template report has got one page.

 

Further, printing of the "Data" band row starts. This happens in the following way:

 

1.the BeforePrint band event is fired;
2.the BeforePrint event of all objects lying on the band is fired;
3.all objects are filled with data;
4.the AfterData event of all objects lying on the band is fired;
5.the BeforeLayout band event is fired;
6.objects are placed on the band, the height of the band is calculated and band is stretched (if it can);
7.the AfterLayout band event is fired;
8.if the band cannot fit on a free space on the page, a new page is formed;
9.the band and all its objects are displayed on a prepared report page;
10.the AfterPrint band event is fired;
11.the AfterPrint event of all the band objects is fired.

 

Printing of the band row occurs as long as there is data in the source. After this, the formation of the report in our case ends. The FinishPage event of a page is fired and finally - the FinishReport event of the "Report" object.

 

So, by using events of different objects, you can control every step of report formation. The key to correct use of events - full understanding of the band printing process, expound in the eleven steps above. So, a lot of operations can be done, by using only the BeforePrint band - any change, done to the object, will also be displayed. But in this event, it is not possible to analyze, on which page will the band be printed, if it stretches, because the height of the band will be calculated on step 6. This can be done with the help of the AfterLayout event in step 7 or AfterPrint in step 10, but in the latter case, the band is already printed and operations with objects do not give out anything. In one word, you must clearly state, at what moment each event is fired and use, those, which correspond with the given task.