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

multiple subreports problem

4 Answers 212 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
gica
Top achievements
Rank 1
gica asked on 12 Jun 2009, 04:09 PM
Hello,

I have to create a report which contains multiple subreports. These subreports are added dynamically at runtime. Everything was going ok till the render time. For some reasons the subreport which is not fit in the current page is displayed on the next page but it is not completed displayed. I understand the fact that if it cannot be displayed in the current page it is displayed on the next one but I cannot understand why it is partially displayed.

For example if a want to display the same report 10 times and on the first page we cand display only 3 of them, the forth one is displayed on the second page but with the same size. Actually the size of the first subreport + the size of free space on the first page get the normal size of the fourth report.
 

This is a code snipped for what I want to do(If you want I can send you a sample application but I can't attach files):
  Color[] srColors = new Color[]
                { Color.Red,
                Color.Orange,
                Color.Yellow,
                Color.Green,
                Color.Blue,
                Color.Indigo,
                Color.Violet } ;
            for (int i = 0; i < 27; i++)
            {
                SubReport sr = new SubReport();               
                sr.ReportSource = new ColorReport(srColors[i%7]);
                sr.Dock = DockStyle.Top;
                this.detail.Items.Add(sr);              
            }

Thanks in advance,

4 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 15 Jun 2009, 11:58 AM
Hello gica,

You must always define Size and Location for any report item you create and add to the report. You can find a sample code for multiple subreports being added to "main" report in this forum thread.

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
gica
Top achievements
Rank 1
answered on 15 Jun 2009, 12:35 PM
Tks Steave,
I have fixed the problem.

Regards,
Gica
0
Erik Underbjerg
Top achievements
Rank 1
answered on 03 Sep 2009, 09:10 AM
Hi,

I'm evaluating Telerik Reporting and having trouble getting a decent layout when including several subreports in a main report programatically, using code like the following:

            List<Report> detailReports = new List<Report>(); 
 
            Report keyFigures = BuildKeyFiguresReport(); 
            detailReports.Add(keyFigures); 
            IList<Report> relationReports = BuildRelationsReport(); 
            detailReports.AddRange(relationReports); 
 
            Report report = new PersonReport(); 
            report.DataSource = person; 
            DetailSection detail = (DetailSection)report.Items.FindItem(typeof(DetailSection)); 
 
            foreach (Report detailReport in detailReports) 
            { 
                SubReport subReport; 
                subReport = new SubReport(); 
                subReport.Anchor = AnchorStyles.Left | AnchorStyles.Right; 
 
                subReport.Width = Unit.Cm(17); 
 
                subReport.ReportSource = detailReport; 
                detail.Items.Add(subReport); 
            } 

What I want to achieve is:
- I want each of the subreports to be included in the master report, and the master report should stretch vertically to accommodate them
- I want each of the subreports to stretch horizontally, and match whatever the width of the main report is. Alternatively, specify the width of all the subreports in code, such as above
- I don't want to set the vertical position of the subreports manually, since they have variable sizes

What's happening however, when I do a PDF export is this:
- I get several blank pages in the report
- The subreports *do not* stretch to fill the master report horizontally, eventhough all items in the subreports are set to resize dynamically, and though I've tried many combinations of setting width and/or anchor on the subreports in code (as above)

I'm hoping there's a good solution to getting a dynamic layout of subreports, as it would be a maintenance nightmare to have to set the dimensions and/or locations of all the subreports manually.

Please help :)

//Erik
0
Steve
Telerik team
answered on 08 Sep 2009, 02:08 PM
Hello Erik,

Thank you for contacting us and up to your questions:
  • I get several blank pages in the report: there are several reasons why blank pages might appear in a report - please review the following KB article.
  • The subreports *do not* stretch to fill the master report horizontally: in fact items (sections respectively) in Telerik Reporting can grow only vertically and cannot grow horizontally - this is by design.
Setting location for any item in the report is mandatory as the layout calculations depend on the location of the items.
All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
gica
Top achievements
Rank 1
Answers by
Steve
Telerik team
gica
Top achievements
Rank 1
Erik Underbjerg
Top achievements
Rank 1
Share this question
or