Sometimes we need to create reports with content. In this case, you should first create the report structure and then create the overall report. But I have a question. This is because it is currently unknown how many pages the content element will refer to when the content is rendered. In this case we use anchors. To create an anchor, use the AddAnchor method. When creating an anchor, the report generator saves the current page and compares it with the specified anchor. For example:
AddAnchor(“MyAnchorName”)
This line creates a new anchor named "MyAnchorName". To get the value of the anchor, you should use the GetAnchorPageNumber method. This method returns the number of the page corresponding to the anchor name. If there is no anchor with such name, 0 is returned.
For example:
{GetAnchorPageNumber(“MyAnchorName”)}
After the contents have been created the whole report rendering is in process. Anchors are created during report creation. When the report is rendered, actual page numbers are placed on anchors in the content instead of hyperlinks. Let's see how to use anchors in templates. Create a "master-detail-detail" report that displays a list of products broken down by category. In order to create such a report, we need to prepare two pages. The first page is for content and the second page is for reports. Place two bands on the content page. In the meantime, set up master and detail links. Then place a text component in the Detail band. This ProcessAtEnd text component property must be set to true.
Specify the text representation of the text property as follows:
{GetAnchorPageNumber(component.TagValue)}
The value of the Tag property is used as the anchor name. Enter the Tag property using the following formula.
{Products.ProductName}
{GetAnchorPageNumber(Products.ProductName)}
Components containing expressions are processed at the end of report building. So the value of the Products.ProductName field is equal for all strings (at the end of the list). So when building your content, you need to remember the value of the Products.ProductName field for every string. Use the Tag property for this. On the second page, create a report. The AddAnchor method is called on the Rendering property of the DataBand component (used to build content). This method returns the current page at the moment it is called.
Anchor name is the value of the Products.ProductName field. As a result, the page number is rendered first. Then the second page is rendered and the page number is saved. After rendering the report, the report generator engine returns to the first page and numbers all pages.