Telerik Reporting R1 2017

Page Functions

Note Note

Page aggregates should be used in page sections only (Page Header, Page Footer). Page aggregates are supported in page oriented formats only: IMAGE (TIFF, EMF, BMP, JPEG, GIF, Print), PDF, PPTX, DOCX, RTF, XPS.

PageExec

The PageExec(scope, aggregateFunction) function executes the specified aggregate function in the given scope. It can be used in the page header or page footer of the report. In order to specify the scope in which the aggregate would be evaluated, you need to specify the Name of a Group, Section, or Report Item as a string parameter of the function.

It takes two parameters:

  • scope – determines which data objects are included in the PageExec accumulation. For each instance of the Group/Section/Report Item with the specified Name that occurs on the current page, its data object is accumulated.

  • aggregateFunction – the aggregate that is accumulated for each page. The expression used as an argument of the aggregate function is evaluated against the collected data objects.

For example the expression

= PageExec("lineTotalTextBox", Sum(Fields.LineTotal))

used in a page section (page header or footer) will return the LineTotal summary for every single page of the report.

PageNumber

The PageNumber(scope, aggregateFunction) function allows resetting the page number on any page based on the data in the report. This allows for the generation of flexible page section content such as separate page numbering for each Group/Section/Report Item occurrence, “continues on next page” logic, and simultaneous overall report book numbering and specific numbering inside each of its reports.

Under the hood, this function will call the PageExec function with the provided scope and aggregateFunction arguments. Based on the PageExec function result it will return a scoped page number. The scoped page number is the number of subsequent pages of the report up to the current page, where the value returned from the PageExec function stays exactly the same. When the value changes, the scoped page number is reset and a new page number sequence is started. It can be used in the page header or page footer of the report. In order to specify the scope in which the aggregate function expression would be evaluated, you need to specify the Name of a Group, Section, or Report Item as a string parameter of the function.

It takes two parameters:

  • scope – determines which data objects are included in the PageExec accumulation. For each instance of the Group/Section/Report Item with the specified Name that occurs on the current page, its data object is accumulated.

  • aggregateFunction – the aggregate function expression is evaluated against the collected data objects. If no aggregate function is present the First(expression) aggregate function will be used by default.

For example the expression

= PageNumber("group1", Fields.GroupName)

used in a page section (page header or footer) will first evaluate the expression against the specified scope. Then, if the current page is the first page where this value occurs, it will return '1' as the page number. For each subsequent page where the result of the evaluation stays exactly the same, the page number will be incremented. When the result of the evaluation changes, the current page number will be reset and a new sequence will be started.

The PageNumber function has an overload which takes a PageExec function as a single parameter. The result is the same whether you use the shorthand notation with two parameters or the longhand notation with a single PageExec function argument:

= PageNumber(PageExec("group1", Fields.GroupName))

Note Note

Where it is applicable, use page breaks for the Group/Section/Report Item (or its parent section) used in the scope parameter. This will prevent instances of the specified scope belonging to different sequences of pages to be present on the same page. The most common example is the last page number from the first page sequence to be overlapping on the same page with the first page number from the next page sequence. If such scenario occurs, use First(expression) or Last(expression) aggregates in the aggregateFunction parameter to specify which page sequence you would like to use to display the page number, as shown in the image below:

Reset Page Last First
Caution note Caution

Using PageNumber or PageCount functions inside conditional statements implemented with the Conditional and Null-coalescing operators (?: and ??) may prevent these functions from executing for a particular page. This will disrupt the current page sequence and the functions may produce unexpected results. In this case it is recommended to use the Conditional Functions instead of the above operators.

PageCount

The PageCount(scope, aggregateFunction) function allows keeping track of multiple scoped page counts simultaneously for each Group/Section/Report Item. This function will use the PageNumber and PageExec functions internally to calculate the scoped page count for each sequence of pages where PageExec returns the same value. Each sequence of pages is determined by the given scope and aggregateFunction. It can be used in the page header or page footer of the report. In order to specify the scope in which the aggregate function expression would be evaluated, you need to specify the Name of a Group, Section, or Report Item as a string parameter of the function.

It takes two parameters:

  • scope – determines which data objects are included in the PageExec accumulation. For each instance of the Group/Section/Report Item with the specified Name that occurs on the current page, its data object is accumulated.

  • aggregateFunction – the aggregate function expression is evaluated against the collected data objects. If no aggregate function is present the First(expression) aggregate function will be used by default.

For example the expression

= PageCount("group1", Fields.GroupName)

used in a page section (page header or footer) will find all sequences of pages where the Fields.GroupName expression in the provided scope evaluates to exactly the same value and then return the page count in the current sequence of pages.

The PageCount function also has an overload which takes a PageExec function as a single parameter. The result is the same whether you use the shorthand notation or the longhand notation:

= PageCount(PageExec("group1", Fields.GroupName))