|
In PowerBuilder, you can use DataWindows to display and report on database data. You can report on specific data and can dynamically create DataWindows at runtime to report on data selected at runtime.
Grouping Data
In DataWindows, you can group rows for reporting purposes. These groups are called groups and can be used in the DataWindow and in reports to:
Specify page breaks and page numbering
Specify header and trailer information for groupings of information
Report on information in specific groups of rows
For example, if you make column 1 (Dept_Nbr) a group, you can force a page break each time the department number changes, and can report on information for each department in the DataWindow.
TIP: If the rows of the DataWindow are not sorted in the data source, sort them in the DataWindow before you use them in a group. PowerBuilder does not sort the data automatically when you create a group.
Multiple Groups
You can have as many groups as you want in a DataWindow. PowerBuilder assigns each group a number (or level) when you create the group. The first group is level 1, the next level 2, and so on.
The numbering indicates the order of precedence for the groups. Level 1 is the primary group and each subsequent level is a sub-level within the previous level. For example, if group 1 contains column 1 (Dept_Nbr) and group 2 contains column 3 (Location) and you specify the new page option for both groups, a new page will occur each time the department number changes and each time the location changes within a department number.
Header and Trailer Areas
When you create a group, PowerBuilder creates two new DataWindow areas (a header area and trailer area) for the group. Each area is identified by a bar containing the name of the area, the group, the number of each column in the group, and an arrow pointing to the area.
In the header area, you specify information that you want to display at the top of each page of information in the group. For example, if you group the rows by department number, you might want the header to identify how the information is grouped by displaying the department number.
In the trailer area, you specify footer information for the group. This information displays after the last line each value in the group. For example, you might want to provide totals for the each group within a group in the trailer.
TIP: You can include columns, text, and computed fields in the header and trailer areas of a group.
Groups and Expressions
You can also use groups in expressions in aggregate functions in the header or trailer areas of the group and in computed columns. For example, if a column in the DataWindow is salary, you can use a group in the Percent function in a computed column to display the percentage each salary is of the total salary for the group.
Dynamic DataWindows
When you use dynamic DataWindows, you can control the contents and appearance of the DataWindow at runtime. Using dynamic DataWindows, you can build an application in which the end users specify the data that will be retrieved from the database and how it will look (the layout and formatting) and then the applications creates a DataWindow that meets the users' specifications.
|