If you have created multiple drill-through reports, you know that the report navigation works in one direction and that some users struggle to find the best method to navigate back to a previous report. The report toolbar contains navigation controls including a Back button for the previous report in a chain of linked reports but many users don’t find this intuitive. A common user experience paradigm in many well-designed web applications places a series of hyperlinks at the top of a page indicating both the path that brought the user to the page they’re viewing and a path for navigating back to any page along that path. This is a breadcrumb trail of hyperlinks. Reporting Service provides a means to navigate to any other report deployed to the server but it does not have any type of HTML report item that would allow you to build a series of embedded hyperlinks or anchor tags.
This technique shows you how to build a series of breadcrumb hyperlinks that will allow your users to see where they’ve been and to navigate back to any report along the trail.
- Reporting Services 2000
- Reporting Services 2005
- Reporting Services 2008
*The example used in this recipe is based on SSRS 2008 but this technique will work in earlier versions.
What You’ll Need
- Series of reports with report navigation actions
- Report parameter used to track the breadcrumb trail
- Custom code function to build an ad-hoc query
- Dataset used to provide the breadcrumb data
- Matrix data region containing textbox report actions
Figure XX-1 shows an example of a breadcrumb trail in the report header of a detail report. Note the progressive drill-through path of reports the user opened en route to the current report.
In the production implementation of this technique, report actions could be implemented using any of the compatible report items, including textboxes, images, a grouped table, matrix, list or chart data points as the report action source object. The purpose of this recipe is to demonstrate the breadcrumb technique and not the complexities of embedded report actions. As such, we will be using a simple textbox on the report body to navigate between sample reports. These reports will not have any data sources or datasets other than the one required for this technique.
Designing the Report
In the end, you will have four almost identical reports designed to demonstrate the technique. You will start by designing one report with the base functionality for all reports and then create three copies of this report, rename them and make the necessary modifications.
1. Create a new report named Breadcrumb Report 1.
2. Drag and drop the report name from the Built-in Fields to create a title textbox and style the report header as you typically would with a large, bold font, horizontal line, etc, as you see in Figure 1.
3. In the report body, about an inch or three centimeters below the line, add a textbox to use as the report action source object. The user will click this text to navigate to the next report. Add some appropriate text to this textbox to indicate that it’s a link to the second report.
In a more sophisticate production report, this textbox would be replaced with other report items or data regions with appropriate report actions.
A report parameter is used to pass the report navigation history to the target report. With each new report in the navigation chain, the name of that target report will be added to a comma-separated string passed in the parameter. This parameter will only be used internally and not shown to the user.
4. Add a report parameter named CallingReports.
5. Set the parameter to accept a Null value and set the visibility to be Hidden.
A dataset query will be used to drive a matrix data region to contain the report links. This query will be built using an expression and custom code function. Before we put this part into place, we must create a static query to generate the metadata for the dataset. This dataset will not actually consume any real data but a dataset must have a valid data source, And of course a data source must have a valid connection string to satisfy this requirement.
6. Create a new dataset and name it LinksQuery.
7. Any valid shared or embedded data source may be used for this dataset because data will not actually be read from a database. Create or select a data source and select any local or remote server and any valid database. I’ve used the localhost server and the Master database in this example.
8. For the query, type:
SELECT Null As Link
This is only a temporary placeholder to generate a field object named Link. The actual query string will be generated in a custom code function and expression.
A Matrix will be used to display each of the report links, each separated by a right angle bracket, >. Only the column header cells will be used in the Matrix.
9. Add a matrix data region to header area of the report body.
10. Drag the Link field to the Column Groups list to create a new group and group header.
11. Add a new column to the right, inside the group.
13. Right-click in the header cell for this column and add the following expression:
=IIF(Fields!Link.Value = Last(Fields!Link.Value, “LinksQuery”), “”, “>”)
14. Choose both of these cells and set the Color to Blue.
15. Set the text in the first cell to be underscored to make it look like a hyperlink.Compare the matrix shown in Figure XX-5 to validate your design
16. Select the entire matrix and remove all borders using the toolbar or ribbon.
17. Resize the second row containing the data cells to reclaim this unused vertical space. Reduce the height of this row to make it as small as possible.
18. Add a textbox to body of the report.
19. Right-click and choose Textbox Properties.
20. On the Actions tab, create a report action by choosing the radio button Go to report.
21. The destination report doesn’t exist yet so you will just type this value into the drop-down list. Type Breadcrumbs Report 2 into the Specify a report property.
22. Click the Add button to add a new target report parameter. If this report has previously been created, this parameter would be available for selection. Type CallingReports in the Name column.
23. Click the expression button (fx) next to the Value column and type the following into the Expression window:
=IIF(IsNothing(Parameters!CallingReports.Value), Globals!ReportName, Parameters!CallingReports.Value & “, ” & Globals!ReportName)
24. Close and save the Expression dialog and use Figure XX-6 to verify these settings.
25. Click OK to save these settings and close the Text Box Properties dialog.
26. Edit the report properties and add the following code to the Code window:
Function ListToLinksSQL(List As String) As String
Dim sTargetReport() As String
Dim sReport As String
Dim sOut As String
sTargetReport = Split(List, “, “)
For Each sReport In sTargetReport
If sOut <> “” Then sOut &= ” UNION “
sOut &= “SELECT ‘” & sReport & “‘ AS Link”
27. Edit the dataset properties.
28. Replace the query command text with the following expression:
29. Save and close the report.
30. Create three copies of the Breadcrumbs Report 1, named:
Breadcrumbs Report 2
Breadcrumbs Report 3
Breadcrumbs Report 4
If you are using BIDS, the easiest way to add copies of a report to the project is to select the first report in the Solution Explorer and then use Ctrl-C and Ctrl-V to copy and paste a new file, then rename it. In Report Builder 2.0, use the Save As? feature to save copies of the file to the same folder as the original.
31. Modify each reports so that the report action targets the next report in the sequence and the last report back to the first.
The Breadcrumbs Report 2 report action should navigate to Breadcrumbs Report 3. Breadcrumbs Report 3 should navigate to Breadcrumbs Report 4, and Breadcrumbs Report 4 should navigate back to Breadcrumbs Report 1.
Preview the first report and click the link to navigate to the second report. Continue to follow the links on each subsequent report and note the accumulated breadcrumb links in the report header. Click any of the links to navigate to any of the reports in the series.
Several variations are possible. This technique will display one link per distinct report. If the user were to navigate from Report 1 to Report 2 and then back to Report 1, A link for Report 1 would be displayed only once. Adding another parameter to capture the current date and time for each drill-through would provide a mechanism to group on each duplicate report and to sort the list in the order of navigation.
2 thoughts on “Drill-through Report Link Breadcrumbs”
The pictures are missing. 🙁
Do you mind if I quote a couple of your articles as long as I provide credit and sources
back to your site? My blog is in the exact same area of interest as yours
and my users would certainly benefit from some of the information you present
here. Please let me know if this alright with you. Many thanks!