Kbase 17383: How to include total pages in Actuate
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
How to include total pages in Actuate
Page Number Example Report
This document describes the report pagenum.rod. Here we are demonstrating the ability to have a page number in the report show where it is in relation to the total number of pages. For example, Page 4 of 50. In order to accomplish this, all pages in the report need to be generated, then the Report Factory can go back to the pages and adjust the control that is displaying the page number. (Remember all this is possible since the ROI is a persistent object containing persistent objects.)
The report is constructed from the demonstration sports database. It queries the customer table and selects the cust-num, name, balance, and sales-rep fields. The Report's PageHeader slot frame contains the labels for all the fields being displayed. It is displayed on every page. The Report's Content slot frame is showing the database field information.
Follow these steps to create the page number control in your report:
1. In the Structure Pane of the Design Editor, locate the Page component.
2. Right mouse click on this component and choose Edit Layout... .
3. From the Drawing/Graphics Palette, drag a label control onto the page where you want to see the page number information.
4. Horizontally resize the control so it will be able to show the entire page number phrase "Page # of ####".
5. Right mouse click on this label control and choose the rename option.
6. Rename the control to be "PageNoDisplay".
7. Choose File « Close to close the Page Design Editor.
Adjusting the Control's properties:
1. In the Structure Pane of the Design Editor, select the PageNoDisplay control and double click on it to access the Component Editor.
2. Locate the Text property of the control and set its value to "Page 1 of "
3. Locate the ObjectVariable property and set its value to "PageNoDisplay". Setting this property allows the control to be accessed from other areas of the Report.
4. Choose Close to Close the Component Editor.
Finish Method for the PageNoDisplay Control:
1. In the Structure Pane of the Design Editor, select the Report component.
2. Double click on the Report component to access the Component Editor.
3. Change to the Variables tab.
4. Create a variable named NumPages as an Integer (instance and public)
5. Change the tab to be on the Methods tab.
6. Locate the Subprocedure Finish and select it. The Finish() method is called after all the pages of the report have been generated. This is the method used to add code to go through the report page by page in order to calculate the total number of pages and add the page number in relation to the total number of pages.
7. Choose the Override button.
8. Add the following code prior to the Super::Finish call.
Dim curPage as NewReportApp::Page
Dim curPageNum as Integer
Dim iter As AcIterator
Set curPage = GetPage()
curPageNum = 0
NumPages = 1 + GetPageList().GetPageCount() - GetPage( ).GetPageIndex()
Set iter = GetPageList.Pages.NewIterator()
iter.SkipTo( GetPage( ).GetPageIndex() )
Do While iter.HasMore( )
Set curPage = iter.GetNext( )
curPageNum = curPageNum + 1
curPage.PageNoDisplay.Text = "Page " & Str$(curPageNum) & " of " Str$(NumPages)
Loop
Code
What it Means
Dim curPage as NewReportApp::Page
Defines an object called curPage that is a Page object
Dim curPageNum as Integer
Variable definition to determine what page we are on
Dim iter As AcIterator
Defines a mechanism to iterate through the completed pages of the report.
Set curPage = GetPage()
Returns the current page
curPageNum = 0
Initialize curPageNum variable at 0
NumPages = 1 + GetPageList().GetPageCount() - GetPage( ).GetPageIndex()
Calculates the total number of pages in the report.
GetPageList().GetPageCount() returns the list of all pages contained in the report and counts the number of pages in the returned list.
GetPage().GetPageIndex() returns first page of the report and gets the page number
Set iter = GetPageList.Pages.NewIterator()
Initialize the object to locate objects within the report
iter.SkipTo(GetPage().GetPageIndex())
Finds the first page in the report and returns the page number
Do While iter.HasMore( )
Starts loop to iterate through pages until there are no more
Set curPage = iter.GetNext( )
Gets the next page
curPageNum = curPageNum + 1
Increments the value of the current page
curPage.PageNoDisplay.Text = "Page " & Str$(curPageNum) & " of " Str$(NumPages)
On the current page, set the text property of the PageNoDisplay control to be the concatenated string of "Page " , curPageNum and NumPages. The function Str$ converts a numeric expression to a string.
9. Choose the Update button then the Close button to save your changes and close the Method Editor.
10. Choose Close to close the Component Editor.
11. Test and run your report.
Progress Software Technical Support Note # 17383