Report Authors / Design Reports / Design Section Reports / Interactivity / Bookmarks
Bookmarks

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.

Set up basic bookmarks

  1. From the toolbox, drag and drop a TextBox control onto the Detail section.
  2. Double-click the Detail section of the report. This creates an event-handling method for the report's Detail_Format event.
  3. Add the following script to set up bookmarks. 
    Visual Basic.NET code. Paste INSIDE the Detail Format event.
    Copy Code
    Detail.AddBookmark(TextBox1.text)
    
    C# code. Paste INSIDE the Detail Format event.
    Copy Code
    Detail.AddBookmark(TextBox1.Text);
    

Set up leveled or nested bookmarks

Leveled or Nested Bookmarks in a Section Report

Bookmarks can be nested to reflect a hierarchical structure; this is sometimes called a parent-child relationship.

  1. 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.
    Connection String
    Copy Code
    method=POST;headers={"Content-Type":"application/json"};body={ "query": "{employees{country, city, superior{firstName,lastName,title}}}" };jsondoc=https://demodata.mescius.io/northwind/graphql
    

    JSONPath
    Copy Code
    $.data.employees[*]
    
  2. From the Report Explorer, drag and drop country and city onto the Detail section.
  3. Double-click the Detail section of the report. This creates an event-handling method for the report's Detail_Format event.
  4. Add the following script to set up leveled or nested bookmarks.
    Visual Basic.NET code. Paste INSIDE the Detail Format event.
    Copy Code
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text)
    
    C# code. Paste INSIDE the Detail Format event.
    Copy Code
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text);
    

Nest grandchild bookmarks and use bookmarks in grouping  

Nested Grandchild Bookmarks in Grouping 

  1. Follow Step 1 of the previous section to create a new section report and bind the data.
  2. From the Report Explorer, drag and drop country, city, and superior.title fields onto the Detail section.
  3. Double-click in the Detail section of the report. This creates an event-handling method for the report's Detail_Format event.
  4. 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.
    Visual Basic.NET code. Paste INSIDE the Detail_Format event.
    Copy Code
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text + "\\" + txtsuperior_title1.Text)
    
    C# code. Paste INSIDE the Detail_Format event.
    Copy Code
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text + "\\" + txtsuperior_title1.Text);
    
  5. Add a Group Header section to the layout and set its DataField property to country.
  6. Double-click in the Group Header section of the report. This creates an event-handling method for the report's Group Header Format event.
  7. Add the following script to set up a bookmark for each instance of the country group.
    Visual Basic.NET code. Paste INSIDE the Group Header Format event.
    Copy Code
    GroupHeader1.AddBookmark(txtcountry1.Text)
    
    C# code. Paste INSIDE the Group Header Format event.
    Copy Code
    GroupHeader1.AddBookmark(txtcountry1.Text);   
    

     

Add bookmarks to a predefined page

Bookmarks to a Predefined Page

To create and add special bookmarks to the bookmarks collection at run time, add the bookmarks to the report document's page collection.

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.
  1. Go to the Script tab of the report designer.
  2. Select ActiveReport as Object and ReportEnd as Event. This creates an event-handling method for the ReportEnd event.
  3. Add the following script to create bookmark for the pages.
    Visual Basic.NET code. Paste INSIDE the ReportEnd event.
    Copy Code
    rpt.Document.Pages(0).AddBookmark("Page1", 1)
    rpt.Document.Pages(1).AddBookmark("Page2", 2)
    rpt.Document.Pages(2).AddBookmark("Page3", 3)
    
    C# code. Paste INSIDE the ReportEnd event.
    Copy Code
    rpt.Document.Pages[0].AddBookmark("Page1", 1);
    rpt.Document.Pages[1].AddBookmark("Page2", 2);
    rpt.Document.Pages[2].AddBookmark("Page3", 3);
    

Combine parent report and subreport bookmarks

Combined Parent Report and Subreport Bookmarks

  1. Create a new section report and bind the data as Step 1 of another section. This will be the parent report.
  2. From the Report Explorer, drag and drop the country field onto the detail section of the parent report.
  3. Double-click the Detail section to create an event-handling method for the report's Detail Format event.
  4. Add the following script to create a bookmark for each instance of the country field in the parent report.   
    Visual Basic.NET code. Paste INSIDE the Detail Format event of the main report.
    Copy Code
    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
    
    C# code. Paste INSIDE the Detail Format event of the main report.
    Copy Code
    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"));
    }
    
  5. Drag-drop Subreport control onto the design area. By default, the ReportName property is set to SubReport1.
  6. Create a new Section report with the name 'SubReport1', which will be a subreport to the parent report.
  7. Bind a newly created report to data as described in Step 1 of the section above. 
  8. From the Report Explorer, drag and drop the city field onto the detail section of the subreport.
  9. Double-click in the Detail section to create an event-handling method for the subreport's Detail Format event.
  10. Add the following script to create a bookmark for each instance of the city field in the subreport.
    Visual Basic.NET code. Paste INSIDE the Detail Format event of the subreport.
    Copy Code
    Detail.AddBookmark(CType(rpt.ParentReport.Sections("Detail").Controls("txtcountry1"), TextBox).Text + "\" + txtcity1.Text)
    
    C# code. Paste INSIDE the Detail Format event of the subreport.
    Copy Code
    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.