External subreport

Stimulsoft Reports.NET discussion
Post Reply
mira
Posts: 1
Joined: Wed Jul 13, 2016 11:21 am

External subreport

Post by mira »

Hello,

I would like to create external subreport which will be reusable in many main reports.
Datasource is dataset with two tables - master and detail with one common column.

I have problem to set relationship between reports due to problem with setting Databand's MasterComponent in subreport.

Code: Select all

void report_GetSubReport(object sender, StiGetSubReportEventArgs e)
		{
			StiReport subReport = new StiReport();
			subReport.Load("subreport.mrt");

			subReport.RegData("ds", _Dataset);
			
			var data = (StiDataBand)subReport.GetComponentByName("Detail");
			var parentC = parentReport.GetComponentByName("DataMain");
			data.MasterComponent = parentC;   // this has no effect
			subReport.Compile();
			e.Report = subReport;
		}
Result is that detail datatable is not filtered by value set in relationship and always rendered all rows.

How can I do this?

Thank you for help,
mira
Attachments
master_detail.zip
(8.37 KiB) Downloaded 119 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: External subreport

Post by HighAley »

Hello.

Unfortunately, it's impossible to do it this way. This works for internal sub-reports only.
You should add filtration on a variable to the data band on the sub-report and pass the value of the variable to sub-report in this event.

Thank you.
Post Reply