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

Making subreport width fill its parent width

13 Answers 1856 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
LE DREAU Steeve
Top achievements
Rank 1
LE DREAU Steeve asked on 02 Apr 2010, 04:48 PM
Hi Telerik team,

I'm currently facing to a problem that really limits my field of action,let me explain it with a simple example (though the designer, not through the code) :
I have two reports :
- Masterreport
- DetailReport

Into Master report detailsection, I add a subreport control. I set its reportsource to DetailReport, its backcolor to blue and its dock property to Top.
Into Detail report, I remove header and footer sections, and I set its detailsection.backcolor to red.
Finally, I set their width to a thin one like 10cm.

When previewing the report, I see that my subreport doesn't filled its parent control width. With use of backgroundcolors, I saw that it's really MasterReport's SubReport control that wasn't horizontally filled, not it's reportsource. I really would like to make it fill !

When searching a solution into this forum, I saw that you tell to set Location of subreport or something like that but I don't understand what to do exactly.

Thanks for all,
Regards

Steeve

13 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 07 Apr 2010, 03:16 PM
Hi Steeve,

We're not sure we understand your concerns and the behavior you describe is the correct one and by design (unless we misunderstand your point). To avoid any confusion, we would appreciate if you modify the attached project to reflect the problem or if it is showing what you think is wrong - please elaborate.
If you want the report used in the subreport to stretch itself to the same width as the master report - this cannot be achieved automatically, but you can always do it with some code. Place the following line just after the InitializeComponent() method of the master report:

this.subReport1.ReportSource.Width = this.Width;

Regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 07 Apr 2010, 04:19 PM
Hi,

I've tried to use your example but it didn't worked because of an "object not set to an instance..." bug. I've tried debug it but I didn't found the error.
I have a project sample with 3 methods (with yours in report's constructor, with anchors and with dock fill) that I've sent through a support ticket (ID 297636) and I cannot send it to the forum due to the extension. Please have a look to this ticket and tell me what I did wrong.

My final goal is to have a text into a subreport that fill the entire width of the report.

Many thanks

Regards
Steeve

0
Accepted
Steve
Telerik team
answered on 08 Apr 2010, 08:58 AM
Hi Steeve,

The project I've send works fine on another machine as well, so I guess the issue is that you are not using the latest internal build (v. 4.0.10.329). You can download it from your account and after installing it, you should be able to run the project without problems.
Anyway I've reviewed the project from your other thread and still do not see what is the problem - everything behaves as expected.
"My final goal is to have a text into a subreport that fill the entire width of the report." - it does that even now. Probably the confusion on your end comes from the fact that you want the report to occupy the whole physical page space (i.e. width taken from the PageSettings). While in reality the report width is defined by the width of the detail section. So if your detail section is 10cm, this is what would be shown on the paper only. In order to stretch this depending on the pagesize or layout you should do that manually with code e.g. add the following lines to your MasterReport2 report right after InitializeComponent():

Me.Width = Me.PageSettings.PaperSize.Width - Me.PageSettings.Margins.Left - Me.PageSettings.Margins.Right
Me.SubReport1.ReportSource.Width = Me.Width

If your layout is LandScape, you should change the Top and Bottom margins respectively.

Regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 08 Apr 2010, 09:57 AM
Hi,

Perfect ! It works very well ! Thanks for all !

Regards

Steeve
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 10 Feb 2011, 11:42 AM
Hi,

How about labels ? This workarround doesn't resize subreport. If my subreport reportsource is larger than subreport container, this one is resized to get the reportsource's width.

Thanks,
Regards

Steeve
0
Steve
Telerik team
answered on 14 Feb 2011, 08:23 AM
Hello Steeve,

As you have correctly pointed out, the SubReport item is container similarly to the report sections. The main thing about a container is that it grows to accommodate its children. So if the ReportSource of the SubReport item is larger, it would grow and this is expected behavior. That is why the code I've provided in my previous reply sets the width of the ReportSource and not of the SubReport i.e. Me.SubReport1.ReportSource.Width.
Again as explained in previous reply, the report width is defined by the width of the detail section, which as mentioned above is a container as well. So if there are items in it, which total width is greater than the width you're trying to specify, it simply won't shrink as it is bound to accommodate its children and this behavior is by design as well.

Hope this clears any further confusion.

All the best,
Steve
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 14 Feb 2011, 08:56 AM
Hi,

Thanks for your answer. It's clear but the behavior is not as we would expect. Is it possible to fix the width of master report to make it's child bound to its width ? If the child report is larger, it will be truncated.
This way, we could have some layout master reports (ie Labels using templates) and child reports that would have Data.
In our development, it is exactly what we do : we have many page layouts, many child reports that display different things, and our clients can choose which layout to use with which data to print. If they choose a data template larger than the layout one, it will be truncated. At this moment, the layout page is changed to get the child width, overwriting the labels layout.

I hope we can have this fonctionalty (MaxWidth or fixed width for detail section)

Thanks
Regards

Steeve
0
Steve
Telerik team
answered on 16 Feb 2011, 05:12 PM
Hi Steeve,

We do not have plans to change the current behavior of the container items, so we suggest you change your layout logic to fit that of Telerik Reporting and not the other way around.

Greetings,
Steve
the Telerik team
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 16 Feb 2011, 05:29 PM
Hi,

I don't know if I misunderstood what you said, so I would like to be sure that there's no solution for what we need :
I have a report with a SubReport in its Details Section. This report has a 15cm width
I have a second report with some datas displayed into it. This report has a 20cm width.

I would like to have a final report which width would be 15cm and not 20cm (so I don't want my subreport to enlarge the master report). Is it possible ?

The main goal of this is to create different master reports that have different labels settings and layout and only one report that will have datas and will be the report source of subreport. So even if the master's subreport container width is larger or thiner than the subreport.reportsource one, the width of the master report won't change but the subreport.reportsource width will be the master width.
I think it's a major feature to avoid creating many combinations of reports.

When I try to set the width of subreport.reportsource, the reportsource is already set, so the subreport container has changed it's width to fit the reportsource one.

Thanks
0
Steve
Telerik team
answered on 21 Feb 2011, 03:14 PM
Hello Steeve,

Your understanding is correct and there is no way to disallow a container item from growing if the child is bigger.

Regards,
Steve
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Adrian
Top achievements
Rank 1
answered on 13 Mar 2012, 06:33 AM
The solution proposed above

this.subReport1.ReportSource.Width = this.Width; 

no longer seems to work? Using Q3 2011.

Or could it be because my sub-report contains a Chart that fills the entire report?

Situation is that I have my master report which is Portrait, but my sub-report is Landscape.

I want the Lanscape sub-report to shrink to fit the master report.

I have tried different combinations of setting the Docking and Anchoring and AutoLayout on the chart in the sub-report - but it always is full size in the master report.
0
Adrian
Top achievements
Rank 1
answered on 13 Mar 2012, 07:04 AM
It would be nice to have a solution that does not require report parameters.

Here is mine though.

The sub-report now has a float Parameter called ReportWidth, default to zero.

and this NeedDataSource method

void ChartReport_NeedDataSource(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.Report processing = (Telerik.Reporting.Processing.Report)sender;
 
            double reportWidth = 0;
            Double.TryParse(processing.Parameters["ReportWidth"].Value.ToString(), out reportWidth);
             
            if (reportWidth > 0)
            {
                Unit unit = Unit.Cm(reportWidth);
                float currentWidth = processing.Width.Value;
 
                // Set Width
                chart1.Width = unit;
                processing.Width = unit;
 
                // Set Height
                chart1.Height = Unit.Cm(chart1.Height.Value * (reportWidth / currentWidth));
                Telerik.Reporting.DetailSection detailSection = (Telerik.Reporting.DetailSection)(chart1.Parent);
                detailSection.Height = Unit.Cm(detailSection.Height.Value * (reportWidth / currentWidth));
            }
        }

Is there a better solution?
0
Steve
Telerik team
answered on 16 Mar 2012, 09:46 AM
Hello Adrian,

The behavior you describe is by design, as I've explained in earlier posts, the SubReport item is only a container that would always grow to accommodate the report set as ReportSource. The only way to "fit" a SubReport bigger than the master report is to manually alter its size like you're doing in your second post.

All the best,
Steve
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
Tags
General Discussions
Asked by
LE DREAU Steeve
Top achievements
Rank 1
Answers by
Steve
Telerik team
LE DREAU Steeve
Top achievements
Rank 1
Adrian
Top achievements
Rank 1
Share this question
or