The SubReport report item lets you display one report within another report. It is a container item just like the report sections and grows depending on its children. The screenshot shows a SubReport report item at design-time. This allows you to compose complex reports from disparate report sources. The data for each SubReport can be completely different. For example you could combine a product listing, a sales summary and a list of sales people each in their own sub reports, with each sub report getting data from a different source. You can also pass parameters to SubReports using the Edit Parameters collection editor.
Data Items cannot be used in page sections, because the latter are processed after the report data has been processed. At this moment the report data source is not available anymore.
Page sections are not related to the report itself, but are relative to the paper or screen. Thus page sections of nested/detail reports are ignored and only the page sections of the main report are visible.In order to have sections that repeat on every page similar to page sections, consider using an unbound group (no grouping criteria specified) and set the PrintOnEveryPage property of its sections to True. Be aware that you cannot use PageCount and PageNumber global objects in group sections.
To remove blank vertical space in the detail section of a SubReport, set the Height of the SubReport.ReportSource DetailSection to the height of the tallest item. Sections can grow to accommodate their children but cannot shrink to hide empty space. If you want the detail section to shrink only at runtime you can set the Height property of the DetailSection in the report constructor. Place the Height property assignment code just after the IntializeComponent() method call.
Click the subreport item that you want to change. The selected subreport properties are listed in the Property Browser.
In the ReportSource property, click the Edit Collection (…) button. Load a Report From window opens.
Click Edit Parameters button to add a parameter. Edit Parameters window opens.
Click the New button to add a new parameter mapping.
Assuming you have assigned the ReportSource property the Parameter Name drop down list will contain the names of parameters defined in the subreport report. Select a Parameter Name from the combobox to set the target for this parameter. from the combobox to set the target for this parameter.
Parameter Value combobox allows you to enter value directly, create an "
<Expression>" or a "
<New Report Parameter>".
When you are done, click OK.
How to Set ReportSource for SubReport
In Design view, right-click a SubReport item to which you want to set a report source and click Properties.
In the item's Properties , click ReportSource.
A "Load a Report from" dialog appears which allows you to select a ReportSource.
Select the type of report source you would use to specify a report. For this example we would use Instance Report Source , click that option and select the report that would serve as detail report.
If you have to specify parameters for the report, follow the next step.
Click Edit Parameters button - Edit Parameters dialog appears. Click New. In the Parameter Name column select the name of a report parameter in the detail report. In the Parameter Value , type or select the value to pass to the parameter in the detail report.
var instanceReportSource = new Telerik.Reporting.InstanceReportSource(); // Assigning the Report object to the InstanceReportSource instanceReportSource.ReportDocument = new Telerik.Reporting.Examples.CSharp.Invoice(); // Adding the initial parameter values instanceReportSource.Parameters.Add(new Telerik.Reporting.Parameter("OrderNumber", "SO43659"));
Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource() ' Assigning the Report object to the InstanceReportSource instanceReportSource.ReportDocument = New Invoice() ' Adding the initial parameter values instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("OrderNumber", "SO43659"))
The Standalone Report Designer includes only XmlReportSource and UriReportSource options due to the format of the produced reports. In Visual Studio Report Designer you can use all available Report Sources.
If the report will be displayed in an HTML5 Viewer or Silverlight ReportViewer, the main report is rendered in HTML (XAML respectively) and it is loaded at the client. The sub report is considered as a content of the main report and its Report Source is resolved internally, withouit additional calls to the Reporting REST service (Reporting WCF Service respectively).