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

How to hide subreports if they do not have the data needed to be display

8 Answers 722 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
aj
Top achievements
Rank 1
aj asked on 27 Apr 2008, 03:27 AM
Hi,
I'm really new to Telerik and really love what this thing has done to me so far.

I have a question about Master and SubReport. How can I hide subreport if the subreport do not have the data. Right now the Master and the subreports work well, but if one or two of the sub reports do not have the data from the master report, how do i hide it? because it display an error that should not be seen by the end user....

I really need some help for it in VB because recently i only found them in C#. Thank you.

8 Answers, 1 is accepted

Sort by
0
Accepted
Chavdar
Telerik team
answered on 28 Apr 2008, 11:41 AM
Hello aj,

You can hide the SubReport item by setting its Visible property to false when there is no data. For example:

Private Sub SubReport1_NeedDataSource(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles SubReport1.NeedDataSource  
        Dim subReport As Telerik.Reporting.Processing.SubReport  
        subReport = CType(sender, Telerik.Reporting.Processing.SubReport)  
 
        If (...no data expression...) Then 
            subReport.Visible = False 
        End If 
    End Sub 

Hope this helps. Let me know if you have other questions regarding this functionality.

Best wishes,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
aj
Top achievements
Rank 1
answered on 29 Apr 2008, 09:04 PM
Thanks for the feed back... it really works with some ideas of mine...Thanks again!!
0
GVera
Top achievements
Rank 1
answered on 01 May 2009, 07:17 PM
Will someone help me with my issue?

I have amaster report with 5 sub-reports.  All of them work except for the last sub-report that I cannot see when I do Preview it.  I know there is data that shoudl come back.  I re-checked the parameters and filters of the sub-reports etc.. and was not successful.  is there anything I am missing about sub-reports and how they are arranged in the Detail section of the master report?

Thanks,

Gabe.
0
Steve
Telerik team
answered on 04 May 2009, 12:03 PM
Hi Gabriel Vera,

Try running the problematic report by itself (i.e. not as subreport) by hard-coding a value for its parameter that you know returns data. If it displays data correctly this way, then the problem is most likely with the parameter you pass. You can set breakpoint and debug if you're using NeedDataSource for its binding or display the parameter value in a textbox item if it is set up through the designer. Either way, there is no limit on how many nested subreports you might have and they work the same way unaware of the hierarchy.

Kind 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
Shimoli
Top achievements
Rank 1
answered on 22 Jun 2011, 10:41 AM
You can use following code:       
void LitigationCustomListContactSubReport_ItemDataBound(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.Report subReport = (Telerik.Reporting.Processing.Report)sender;
            subReport.Visible = subReport.ChildElements.Find("detail", true).Length > 0;
        }
If Sub-report has data,then and only then it will display report.
0
Patrick
Top achievements
Rank 1
answered on 22 Jul 2011, 08:49 PM
Excellent, thank you!
0
Ruben
Top achievements
Rank 1
answered on 20 Aug 2015, 05:13 PM

hi! 

it is possible to do something like this

in the standalone report maker?

0
Stef
Telerik team
answered on 24 Aug 2015, 01:44 PM
Hi Ruben,

Please test the approach based on expressions from my post in How to hide subreports that has no data.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
aj
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
aj
Top achievements
Rank 1
GVera
Top achievements
Rank 1
Steve
Telerik team
Shimoli
Top achievements
Rank 1
Patrick
Top achievements
Rank 1
Ruben
Top achievements
Rank 1
Stef
Telerik team
Share this question
or