HOME PAGE | DOWNLOAD | TUTORIALS | XtraReports
Devexpress

Sunday, July 22, 2012

How to: Create a Master-Detail Report using Detail Report Bands

This tutorial describes the steps to create a master-detail report using detail report bands.

To create a master-detail report, do the following.

1.      Start MS Visual Studio (2008 or 2010), and create a new application under any of the supported platforms, or open an existing one.

2.      Add a new blank report to it.

3.      Bind the report to the both the "Categories" and "Products" tables of the sample Northwind database. To do this, check these tables in the wizard's last page, so that a relation between them is created automatically.

In case your master-detail report has different data sources, you should manually create a relation between them. To do this, right-click anywhere in the DataSource Schema, point to Add and select the Relation... item. The Relation dialog will appear, in which you can customize the relation's properties.

4.      To create a detail report, right-click the report's Detail band, and in the menu, point to Insert Detail Report and click "CategoriesProducts".

After this, the following properties of the created DetailReport band should be automatically set:

- the XtraReportBase.DataAdapter property to productsTableAdapter;

- the XtraReportBase.DataMember property to Categories.CategoriesProducts;

- the XtraReportBase.DataSource property to nwindDataSet1.

This means that the DetailReport is properly bound to the data.

5.      From the Field List window, drop the CategoryName and Description fields onto the Detail band.

6.      From the Field List's CategoriesProducts section, drop the ProductName and UntiPrice fields onto the DetailReport's Detail1 band.

Note

Note that these fields must be taken from the CategoriesProducts relation, NOT from the Products table. In the latter case, the report will display only the first record of the Products table for each category, as many times as there are records in each category.

The master-detail report is now ready. Switch to the Preview tab and view the result.

 

No comments:

Post a Comment