This is a migrated thread and some comments may be shown as answers.

Sub-reports render blank results.

1 Answer 49 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 28 Aug 2013, 05:30 PM
I'm trying to build a report programmatically due to the complexity and dynamic nature of the requirement I am faced with.
The best way I can think is to have one 'shell' report that composes many different child reports.

However when I just try to do a light version of the above with a simple (not data-bound) child report that just prints 'hello world!' I get nothing rendered out. When I run the Child report on it's own I receive the expected results.

Below is my code for the shell report

private Telerik.Reporting.Report Build()
{
    Telerik.Reporting.Report mainReport = new Telerik.Reporting.Report();
    Telerik.Reporting.DetailSection detail = new Telerik.Reporting.DetailSection();
 
    mainReport.Items.Add(detail);
 
    Unit unitX = Unit.Inch(0.1);
    Unit unitY = Unit.Inch(0.1);
    SizeU size = new SizeU(Unit.Inch(1), Unit.Inch(0.5));
 
    List<Telerik.Reporting.Report> childrenReports = new List<Telerik.Reporting.Report>();
 
    ExecutiveSummarySection executiveSummary = new ExecutiveSummarySection();
    childrenReports.Add(executiveSummary);
     
    foreach (Telerik.Reporting.Report child in childrenReports)
    {
        Telerik.Reporting.SubReport sub = new Telerik.Reporting.SubReport
        {
            Location = new PointU(unitX, unitY),
            Size = size
        };
        unitY = unitY.Add(Unit.Inch(1));
        Telerik.Reporting.InstanceReportSource childInstanceReportSource = new InstanceReportSource();
        childInstanceReportSource.ReportDocument = child;
        sub.ReportSource = childInstanceReportSource;
        detail.Items.Add(sub);
    }
    detail.Height = Unit.Inch(childrenReports.Count + 2D);
    return mainReport;
    //return executiveSummary;
}


and the 'ExecutiveSumarySection' report:

using AGP.Data.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Reporting;
using Telerik.Reporting.Drawing;
 
namespace AGP.Reports
{
    public class ExecutiveSummarySection : Report
    {
 
        public ExecutiveSummarySection()
        {
            InitializeComponent();
            //DataBindControls();
        }
 
        private void DataBindControls()
        {
             //going to data bind later to EF5 backed repository
            //ModelContextUnitOfWork uow = new ModelContextUnitOfWork();
            //DocumentEFRepository docRepo = new DocumentEFRepository(uow);
 
            //this.DataSource = docRepo.All.ToList();
        }
 
        #region Component Designer generated code
        /// <summary>
        /// Required method for telerik Reporting designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Telerik.Reporting.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule();
            this.pageHeaderSection1 = new Telerik.Reporting.PageHeaderSection();
            this.detail = new Telerik.Reporting.DetailSection();
            this.pageFooterSection1 = new Telerik.Reporting.PageFooterSection();
            this.panel1 = new Telerik.Reporting.Panel();
            this.textBox1 = new Telerik.Reporting.TextBox();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            //
            // pageHeaderSection1
            //
            this.pageHeaderSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(2D);
            this.pageHeaderSection1.Name = "pageHeaderSection1";
            //
            // detail
            //
            this.detail.Height = Telerik.Reporting.Drawing.Unit.Inch(2.1000001430511475D);
            this.detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.textBox1});
            this.detail.Name = "detail";
            //
            // pageFooterSection1
            //
            this.pageFooterSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(2D);
            this.pageFooterSection1.Name = "pageFooterSection1";
            //
            // panel1
            //
            this.panel1.Name = "panel1";
            this.panel1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(2D), Telerik.Reporting.Drawing.Unit.Inch(1D));
            //
            // textBox1
            //
            this.textBox1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0D));
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.2000001668930054D), Telerik.Reporting.Drawing.Unit.Inch(0.40000024437904358D));
            this.textBox1.Value = "Hello World!";
            //
            // ExecutiveSummarySection
            //
            this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.pageHeaderSection1,
            this.detail,
            this.pageFooterSection1});
            this.Name = "Report1";
            this.PageSettings.Margins = new Telerik.Reporting.Drawing.MarginsU(Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D));
            this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Letter;
            this.Style.BackgroundColor = System.Drawing.Color.White;
            styleRule1.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
            new Telerik.Reporting.Drawing.TypeSelector(typeof(Telerik.Reporting.TextItemBase)),
            new Telerik.Reporting.Drawing.TypeSelector(typeof(Telerik.Reporting.HtmlTextBox))});
            styleRule1.Style.Padding.Left = Telerik.Reporting.Drawing.Unit.Point(2D);
            styleRule1.Style.Padding.Right = Telerik.Reporting.Drawing.Unit.Point(2D);
            this.StyleSheet.AddRange(new Telerik.Reporting.Drawing.StyleRule[] {
            styleRule1});
            this.Width = Telerik.Reporting.Drawing.Unit.Inch(6D);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
 
        }
        #endregion
 
        private Telerik.Reporting.PageHeaderSection pageHeaderSection1;
        private Telerik.Reporting.DetailSection detail;
        private Panel panel1;
        private TextBox textBox1;
        private Telerik.Reporting.PageFooterSection pageFooterSection1;
    }
}


Not totally sure what I'm doing wrong here but I was following many similar examples provided in the forums by Telerik Reporting team on doing this type of report.

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 02 Sep 2013, 12:01 PM
Hi Craig,

We have tested the provided method and on our end and the report is shown as expected. Make sure that you use the ReportViewer.ReportSource.

If you need additional assistance please open a support thread and send us a runnable sample that exhibits the unexpected behavior to debug on our end.

Regards,
Peter
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
Craig
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or