What better source for tips and tricks for your beloved Reporting product, than a blog spot right from the kitchen where the product is ‘mixed’. As of this post, we would like to start a small series of tips and tricks that make a developers’ life sweeter. We’re not going to discuss general topics, so if you’re looking for answers for one of those questions – please review our documentation
and our forums
As you can guess, the sub-report item, which lets you display one report within another report is widely used in Telerik Reporting. It lets you compose complex reports from disparate report sources and the data for each sub-report can be completely different. With its help you can create the very much exploited master-detail report scenarios with ease. Wiring up report parameters and accessing the sub-report’s report is straightforward, but a question arises - what should we do if there is no data to be shown in the sub-report under some conditions. Well, we can check if it has data and if it does not contain any - hide it, so it does not take up any unnecessary space and mess up the master report layout . We’re going to use the subreport_ItemDataBound eventhandler for this purpose:
sender, System.EventArgs e)
Processing.SubReport subReport = (Processing.SubReport)sender;
Processing.Report report = (Processing.Report)subReport.InnerReport;
subReport.Visible = Telerik.Reporting.Processing.ElementTreeHelper.FindChildByName(report,
).Length > 0;
The "detail" parameter is the name of the detail section of the report set as Report Source for the sub-report item.
Hope this helps!