New to Telerik Reporting? Download free 30-day trial

Repeat Group Labels when Group Continues on the Next Page

Environment

Product Progress® Telerik® Reporting

Description

Here is what you may do when you want to display the Report group information in a different way, depending on whether it should appear on the 1st group page, on a mid-page for the group, or on the last page for the group.

Suggested Workarounds

The paging information is available only in the Page Sections of the Report - see the Report Structure. In the Group Header/Footer Sections that may be set to appear on each page, there is no information about the current page. For example, it is not known whether the group has records for the current page.
For the above reason, you need to use the Page Sections to display the information based on the page number for the group.

Workaround 1. Display All Group Header Information in the Page Header

Let's consider we have only one group in the Report and each page may contain only 1 or 2 group instances. The first line of the following Expression displays the name of the first group instance on the page. Note that the scope for the function is the name of the TextBox where we display the actual group detail value.

= PageExec("textBox2", Fields.Group) + 
IIF(PageExec("group", Fields.Value) = PageExec("textBox2", Fields.Value), "", "-Continued ") + 
IIF(PageExec("textBox2", Fields.Group) = PageExec("textBox2", Last(Fields.Group)), "", " / " + PageExec("textBox2", Last(Fields.Group)))

On the next Expression line, we determine whether this group is a new one or continues from the previous page. In the latter case, we display "Continued". Note that the first scope is the group name, which assures that the returned value is the first value for the Report group. On the third Expression line, we check whether another group starts on the same page. If so, we display also its name in the Page Header.

Note that we used the Last Aggregate Function. Generally, the PageExec Page Function accepts an aggregate function as second argument. We have skipped the First aggregate function above as it is the default one that would be applied to the Field when an aggregate is omitted.

The demo report demonstrating this approach can be downloaded from our Reporting Samples GitHub Repo - ReportWithGroups.

Workaround 2. Display the Group Header Information in the Page Header Only for Groups that Continue from the Previous Page

For this scenario we have multiple nested Report groups in the Report. We are going to use Group Headers to display the Group information only for the first occurrence of the group instance. Therefore, we keep GroupHeader > PrintOnEveryPage as False. If the group continues we will use the Page Header to display its customized group header information. Here is a sample Expression that would display the grouping field/name followed by "-Continued":

= IIF(PageExec("group", Fields.Value) = PageExec("textBox2", Fields.Value), "", PageExec("textBox2", Fields.Group) + "-Continued ")

It is very similar to the second line of the Expression we used in the first approach. Note that you need to use it for each of the nested groups, with the corresopnding group scope and name of the TextBox that displays the group detail data.

We also have to take care of the corner case, when a group starts at the bottom of the previous page without displaying an item there. In this case, the group name won't appear on the second page's Page Header as the first detail of the group will be on this page. To fix this, you need to set all groups' properties GroupKeepTogether to FirstDetail (the default is None).

The demo report with four groups can be found in Reporting Samples GitHub Repo - ReportWithFourGroups.

See Also

In this article