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

Auto Grow and Shrink of SubReports

3 Answers 255 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
PJ Rodriguez
Top achievements
Rank 1
PJ Rodriguez asked on 24 Sep 2009, 11:16 PM
I have a main report that contains quite a few subreports. The outline of the main report is below:

------------------------------------
SUBREPORT 1
SUBREPORT 2
SUBREPORT 3

When I generate the report, if SUBREPORT1 does not contain any data I expect the rendered report to look like:

--------------------------------------
SUBREPORT2 DATA
SUBREPORT3 DATA

However, what I am getting rendered is similar to below:
------------------------------------

SUBREPORT 2
SUBREPORT 3

I want SUBREPORT2 to move up closer to the line if SUBREPORT1 does not get rendered. How do I accomplish this? I've played around with the CanGrow and CanShrink properties but that does not seem to solve the issue? Can this be done? Thanks!

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 25 Sep 2009, 08:59 AM
Hi PJ Rodriguez,

The SubReport item acts as a container for the reports and thus it grows according to its children (in this case the report data). However if there is no data, the subreport item would not shrink (it does not have CanGrow/CanShrink) and would keep its default size. What you can do is make the subreport item as small as possible e.g. 0.1mm and this way it would not take up any space when its children do not grow. This of course would be relevant for the items in the report used as ReportSource for that subreport item as well i.e. make sure that when there is no data, the report occupies as little space as possible.
Another possible solution is described in this blog post.

Kind regards,
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.
0
PJ Rodriguez
Top achievements
Rank 1
answered on 25 Sep 2009, 05:28 PM
Thanks Steve.

I was inclined to follow the programmatic way of doing it but when I do that I get the following error:

An error has occured while processing Report '':
Unable to cast object of type 'Telerik.Reporting.Processing.Report' to type 'Telerik.Reporting.Processing.SubReport'.

My code is below:

    Private Sub Ordinances1_ItemDataBound(ByVal sender As ObjectByVal e As System.EventArgs) Handles Ordinances1.ItemDataBound  
        Dim subReport As Processing.SubReport = DirectCast(sender, Processing.SubReport)  
        Dim report As Processing.Report = DirectCast(subReport.InnerReport, Processing.Report)  
        subReport.Visible = report.ChildElements.Find("Ordinance_Details"True).Length > 0  
    End Sub 

Ordinances1 is the subreport and Ordinance_Details is the detail section name in the Ordinances.vb design.
0
PJ Rodriguez
Top achievements
Rank 1
answered on 27 Sep 2009, 04:33 AM
Got this one! The subreport name did not take the first time. Rebuilding fixed it and now it works!
Tags
General Discussions
Asked by
PJ Rodriguez
Top achievements
Rank 1
Answers by
Steve
Telerik team
PJ Rodriguez
Top achievements
Rank 1
Share this question
or