How to: Add a Table of Contents to a Report
- 2 minutes to read
This tutorial describes how to provide a Snap report with an automatically generated hierarchical table of contents.
The tutorial consists of the following sections.
Create a Reporting Application
To get started with this tutorial, create a master-detail Snap report that is bound to the Products and Categories tables of the sample Northwind database (the nwind.mdb file included in the XtraReports installation). Drag-and-drop the CategoryName and Description fields of the Categories data table from the Data Explorer to the body of the document, to create a master report.
Drag-and-drop the ProductName, UnitPrice and UnitsInStock fields of the Categories.Products data table to create a detail report.
For general information on how to create a master-detail Snap report, refer to How to: Create a Master-Detail Report.
Add a Table of Contents to the Report
To add a table of contents to the Snap document, place the text cursor in the position in the document where you wish to insert a table of contents, and click the Table of Contents button in the References tab of the Snap editor's ribbon toolbar. The newly added table of contents will contain no entries.
Table of contents provide the ability to display document fields in different hierarchical levels. To show the document field that is bound to the CategoryName data field in level 1 of the table of contents, click the document field to highlight it.
Then click the Add Text button in the References tab of the ribbon toolbar, and select Level 1 in the invoked drop-down menu.
Next, click the Update Table button in the Table of Contents button group in the ribbon toolbar's References tab, to update the displayed content of the table of contents according to the changes made in the previous step.
- Show the document field in the same way. The document field is bound to the ProductName data field in level 2 of the table of contents.
View the Result
The Snap report with a table of contents is now ready. Click the Print Preview button in the File tab of the ribbon toolbar to view the preview.