How to: Use the XRSubreport Control with Reports V2 Data Sources
- 2 minutes to read
The approach described in this topic is not supported by the Mobile platform.
XRSubreport and CollectionDataSource
To create a report with a subreport in XAF, you can follow the Creating a Master-Detail Report using Subreports tutorial published in the XtraReports documentation, but using the CollectionDataSource instead of binding to data directly. Then, you can register a master report using the PredefinedReportsUpdater.AddPredefinedReport<T> method. No additional steps are required.
XRSubreport and ViewDataSource
The complete example is available in the FeatureCenter application. By default, this demo is installed in the %PUBLIC%\Documents\DevExpress Demos 20.1\Components.NET Core Desktop Libraries\eXpressApp Framework\FeatureCenter path. The master report and its subreport are demonstrated in the following files.
If you choose ViewDataSource, use the same approach described in the previous paragraph, but take into account that the master object's key column is added in the Parameter Bindings Collection Editor dialog demonstrated in the XtraReports tutorial. With the ViewDataSource, you should add the key column manually to the ViewDataSource.Properties collection. The Expression value should refer to the key property of the business class specified by DataSourceBase.ObjectTypeName (e.g., to the BaseObject.Oid property). The image below demonstrates the key column added in the Reports Designer.