[]
In a Section report, bookmark links take you to a location where the bookmark is set on your report. Bookmarks and nested bookmarks appear in the document map for fields, groups, and subreports. You can also add special bookmarks at run-time.
Bookmarks are supported when you preview a report in the Viewer, or export a report in HTML and PDF formats. See Document map for more information. The following sections show setting up bookmarks in some scenarios in XML-based Section reports. Note that the same scripts are equally applicable to Code-based Section reports with cautious use of casing.
From the toolbox, drag and drop a TextBox control onto the Detail section.
Double-click the Detail section of the report. This creates an event-handling method for the report's Detail_Format event.
Add the following script to set up bookmarks.
Detail.AddBookmark(TextBox1.text)
Detail.AddBookmark(TextBox1.Text);
Bookmarks can be nested to reflect a hierarchical structure; this is sometimes called a parent-child relationship.
Create a new section report and bind it to JSON data using the following connection string and JSON path. See JSON Provider for more information.
method=POST;headers={"Content-Type":"application/json"};body={ "query": "{employees{country, city, superior{firstName,lastName,title}}}" };jsondoc=https://demodata.mescius.io/northwind/graphql
$.data.employees[*]
From the Report Explorer, drag and drop country and city onto the Detail section.
Double-click the Detail section of the report. This creates an event-handling method for the report's Detail_Format event.
Add the following script to set up leveled or nested bookmarks.
Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text)
Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text);
Follow Step 1 of the previous section to create a new section report and bind the data.
From the Report Explorer, drag and drop country, city, and superior.title fields onto the Detail section.
Double-click in the Detail section of the report. This creates an event-handling method for the report's Detail_Format event.
Add the following script to set up a bookmark for each superior.title and nest superior.title bookmarks within each city, and city bookmarks in each country.
Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text + "\\" + txtsuperior_title1.Text)
Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text + "\\" + txtsuperior_title1.Text);
Add a Group Header section to the layout and set its DataField property to country.
Double-click in the Group Header section of the report. This creates an event-handling method for the report's Group Header Format event.
Add the following script to set up a bookmark for each instance of the country group.
GroupHeader1.AddBookmark(txtcountry1.Text)
GroupHeader1.AddBookmark(txtcountry1.Text);
To create and add special bookmarks to the bookmarks collection at run time, add the bookmarks to the report document's page collection.
type=warning
Caution: Remember that the page collection does not exist until the report runs, so use this code in the ReportEnd event or in form code after the report has run.
Go to the Script tab of the report designer.
Select ActiveReport as Object and ReportEnd as Event. This creates an event-handling method for the ReportEnd event.
Add the following script to create bookmark for the pages.
rpt.Document.Pages(0).AddBookmark("Page1", 1)
rpt.Document.Pages(1).AddBookmark("Page2", 2)
rpt.Document.Pages(2).AddBookmark("Page3", 3)
rpt.Document.Pages[0].AddBookmark("Page1", 1);
rpt.Document.Pages[1].AddBookmark("Page2", 2);
rpt.Document.Pages[2].AddBookmark("Page3", 3);
Create a new section report and bind the data as Step 1 of another section. This will be the parent report.
From the Report Explorer, drag and drop the country field onto the detail section of the parent report.
Double-click the Detail section to create an event-handling method for the report's Detail Format event.
Add the following script to create a bookmark for each instance of the country field in the parent report.
Private _subRpt As GrapeCity.ActiveReports.SectionReport
Public Sub Detail_Format()
SubReport1.Report = _subRpt
Detail.AddBookmark(txtcountry1.Text)
End Sub
Public Sub ActiveReport_ReportStart()
_subRpt = New GrapeCity.ActiveReports.SectionReport()
_subRpt.LoadLayout(System.IO.Path.GetFullPath("..\..\..\SubReport1.rpx"))
End Sub
GrapeCity.ActiveReports.SectionReport _subRpt;
public void Detail_Format()
{
SubReport1.Report = _subRpt;
Detail.AddBookmark(txtcountry1.Text);
}
public void ActiveReport_ReportStart()
{
_subRpt = new GrapeCity.ActiveReports.SectionReport();
_subRpt.LoadLayout(System.IO.Path.GetFullPath(@"..\..\..\SubReport1.rpx"));
}
Drag-drop Subreport control onto the design area. By default, the ReportName property is set to SubReport1.
Create a new Section report with the name 'SubReport1', which will be a subreport to the parent report.
Bind a newly created report to data as described in Step 1 of the section above.
From the Report Explorer, drag and drop the city field onto the detail section of the subreport.
Double-click in the Detail section to create an event-handling method for the subreport's Detail Format event.
Add the following script to create a bookmark for each instance of the city field in the subreport.
```vbnet
Detail.AddBookmark(CType(rpt.ParentReport.Sections("Detail").Controls("txtcountry1"), TextBox).Text + "\" + txtcity1.Text)
Detail.AddBookmark(((TextBox) (rpt.ParentReport.Sections["Detail"].Controls["txtcountry1"])).Text + "\\" + txtcity1.Text);
11. Preview the main report and navigate to Document Map. You will see bookmarks for city from the subreport nested into bookmarks for country from the main report.