Skip to main content

Create Drill-Through Reports

  • 3 minutes to read

Follow this tutorial to create a drill-through report (a user can click a Category entry to invoke a detail report with Products). This report type keeps the original report compact while still allowing access to more detailed information.

The tutorial involves two main steps:

  • Add a master-detail relationship between “Categories” and “Products” reports within one project.
  • Use detail report parameters to filter records based on the selected category.

Drill-Through report

Prerequisites

This tutorial is based on the reports used in the examples below. To complete the tutorial you need to download the project from one the following examples:

View Example: WinForms Reporting

View Example: Web Reporting

Add a Master-Detail Relationship between Reports

Define a master-detail relationship between Category and Product reports within a single project:

Specify the Navigate to Report action

If you switch to Preview, you can click on a Category value in the table. The Preview window navigates to the detail report that contains all Product entries. The next step explains how to filter this list.

Drill-Through report preview

A Breadcrumb control automatically appears below the Document Viewer toolbar and allows you to navigate back to the original report.

Breadcrumb navigation

Specify Parameter Binding to Display Required Data

You can specify parameters during detail report navigation. Use the NavigateToReportAction.ParameterBindings property to limit displayed records (such as products) to a selected category.

To invoke the Parameter Binding Collection Editor, click the ellipsis button in the Parameter Bindings property. Within this editor, click the Sync button to automatically obtain detail report parameters and set Binding to the data field or parameter of the original report.

Parameter Binding Collection Editor

Set Binding to the CategoryID field.

Specify Parameter Binding

Set the following filter string in the detail report to display product records for the selected category.

Set filter string

Result

Switch to Preview and click on a category entry in the master report. The Preview navigates to the detail report that displays only products related to the selected category.

Drill-Through report

Implement Drill-Down Report at Runtime

The following code snippet shows how to accomplish the same scenario in code:

using DevExpress.XtraReports.Interactivity;
using DevExpress.XtraReports.UI;

namespace Drill_through_example {
    public partial class XtraReportCategories : DevExpress.XtraReports.UI.XtraReport {
        public XtraReportCategories(){
            InitializeComponent();

            // Create a NavigateToReportAction instance and specify its settings
            NavigateToReportAction cellAction = new NavigateToReportAction();
            cellAction.ReportSource = new XtraReportProducts();
            cellAction.ParameterBindings.Add(new ParameterBinding(parameterName: "categoryId",
                sqlDataSource1, "Categories.CategoryID"));

            // Assign the NavigateToReportAction object to the control’s Action property
            tableCell6.Action = cellAction;

        }
    }

    public partial class XtraReportProducts : DevExpress.XtraReports.UI.XtraReport {
        public XtraReportProducts(){
            InitializeComponent();
            FilterString = "[CategoryID] = ?categoryId";
        }
    }
}
See Also