ComponentOne VSView Reporting Edition
Grouping and Sorting Data

After designing the basic layout, you may decide that grouping the records by certain fields or other criteria would make the report easier to read. Grouping allows you to separate groups of records visually and display introductory and summary data for each group. The group break is based on a grouping expression. This expression is usually based on one or more recordset fields but it can be as complex as you like.

Groups are also used for sorting the data, even if you do not plan to show the Group Header and Footer sections.

To add or edit the groups in the report, click the Sorting and Grouping button or in the View menu, select Grouping Window. The Sorting and Grouping dialog will appear. You can use this dialog to create, edit, reorder, and delete groups.

To create a group, use the drop-down list under Group On to select the field you want to use for grouping the data. For complex grouping, you may type an expression instead of a simple field name. For example, you could use "Country" to group by country or "Left(Country, 1)" to group by country initial. To follow along with our report, select "Country" for the Group On expression.

Next, select the type of sorting you want ("Ascending" in our example). You can also specify whether the new group will have visible Header and Footer sections, and whether the group should be rendered together on a page.

NOTE: You cannot use memo or binary (object) fields for grouping and sorting. This is a limitation imposed by OLEDB.

After you enter some data for the first group, a new blank row is appended to the list, so you can keep creating new groups.

Here's what the Sorting and Grouping dialog should look like at this point:

If you add more fields, you can change their order by clicking on the row header (the leftmost gray cell) and dragging the row to a new position. This will automatically adjust the position of the Group Header and Footer sections in the report. To delete a field, press the DEL key.

Once you are done arranging the fields, click OK to dismiss the dialog and see the changes in the Designer. There are two new sections, a Header and a Footer for the new group.

The bar across the top of each section contains some useful tools and information about the section:

On the left of the Group Header, there is a little indented circle. This indicates that the section currently has zero height. You can drag the divider line down to increase the section's Height property. The triangle next to it shows the group's sorting order. You can click this icon to bring up the Grouping and Sorting dialog. After the icons, there are labels that contain the section name and, for group headers, the value of the group's GroupBy property.

Also notice the indented box with a minus sign on the left part of the Detail section's title bar. Clicking this icon collapses and expands the section. This feature is useful when you are designing the report because it allows you to see a group's header and footer on the same screen, without scrolling. Collapsing or expanding a section has no effect on how it is rendered on the page.

If you have been following along, you will see that a Group Header section has been created for the new group. The new section has zero height, so drag its divider line down to open up some room.

To see how groups work, click the Bound Field button, select "Country" from the menu and mark an area in the newly created Group Header Section. Double-click the new field and change its Font property to make the new field stand out a little.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback