Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to create a master-detail report using a Subreport

$
0
0

The Master-Detail Report article in the XtraReports documentation describes how to create master-detail reports in two ways - via the DetailReportBand and XRSubreport controls. The first approach is preferable and can be easily used in XAF. However, if you need to use the second approach, steps required to implement it in XAF should be slightly modified, because generally the class on the Many side of an association does not have a simple property with the master's ID. You can filter a detail report by the master object's ID:

[C#]
usingDevExpress.ExpressApp.Reports;privatevoidsubreport1_BeforePrint(objectsender,System.Drawing.Printing.PrintEventArgse){XRSubreportsubreport=(XRSubreport)sender;subreport.ReportSource.Parameters["MasterID"].Value=((XafReport)xafReport1).ObjectSpace.GetKeyValue(GetCurrentRow());}

For additional information, please see reports in the attached example.

Note, this example is now included as a part of the FeatureCenter demo.

IMPORTANT NOTES
If you use the ViewDataSource (from the ReportsV2 module) for the master report, then you will have to modify your script as follows:

[C#]
usingDevExpress.Xpo;privatevoidsubreport2_BeforePrint(objectsender,System.Drawing.Printing.PrintEventArgse){XRSubreportsubreport=(XRSubreport)sender;subreport.ReportSource.Parameters["MasterID"].Value=((ViewRecord)GetCurrentRow())["Oid"];}
Example Comments

Added By: zhan gao at: 5/23/2012 3:11:04 AM    

The example dosen't support 11.2?

Added By: Anatol (DevExpress Support) at: 6/5/2012 7:17:31 AM    

The example was updated and now works fine with version 11.2.

Added By: Willem de Vries at: 10/24/2012 11:22:38 AM    

Thank you for providing this example.
Whilst the first approach may be preferable for simple reports, i find this example indispensable for creating reports with detail-reports anywhere in the report. The first approach does not give the possibility to continue the master report after the details (e.g. for a section where a customer can sign the contract).

Added By: Raoulw at: 1/22/2013 3:01:25 PM    

Looks like this is broken/Changed for 12.2. I have to change existing subreports based on this sample to set Request Parameters to False, because after updating the dialog shows up. Even if I do that, the Parameters Dialog is shwoing...

Added By: Anatol (DevExpress Support) at: 4/2/2013 10:28:52 AM    

It is required to make the parameter invisible to hide the parameters panel. I apologize for missing this step. I have updated the example.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>