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

Report with subreport set visible to false has issue

4 Answers 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 29 Mar 2017, 07:25 PM

so i was tasked to remove the subreport and to test it out, i made it visible=false.  When i do that i get no data at all.  I have removed it as well with the same issue. any help is greatly appreciated.

The report is really basic, subreport at the top and 10 columns below.

4 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 30 Mar 2017, 09:57 AM
Hello Mark,

Please elaborate how to reproduce the problem locally. We need a step by step instructions how to create the report and what changes should be applied, and details about the result (screenshots and information about the expected result).

In case you need to hide a sub report if does not display any data, please check How to show 'No Data Message' or hide an item in case of No data.


Feel free to create a support ticket and to send us the information in private.

Regards,
Stef
Telerik by Progress
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
0
Mark
Top achievements
Rank 1
answered on 30 Mar 2017, 11:14 AM

So I create datatables in the code then I do this (does work when I don't make the subreport visible - see attachment):

'bottom table                          
 
Dim rptReport As New rptMSVS                          
 
rptReport.DocumentName = strStartTime                          
 
rptReport.tblReport.DataSource = dtBottom                          
 
rptReport.txtDateRange.Value = strDateRange                          
 
rptReport.txtFilters.Value = strFilters                         
 
 'top table - this is what i dont want to show anymore                        
 
Dim rptSummary = New sbrSummary                          
 
rptSummary.DocumentName = ""                          
 
Dim instanceTop As New InstanceReportSource                         
 
 rptSummary.tblSummary.DataSource = dtTop                          
 
instanceTop.ReportDocument = rptSummary                         
 
 rptReport.sbrSummary.ReportSource = instanceTop                          
 
Dim reportBook As ReportBook = New ReportBook                          
 
reportBook.Reports.Add(rptSummary)                         
 
 reportBook.Reports.Add(rptReport)          
 
 
 'add the sheet to the report                         
 
 rptMSVS.Reports.Add(rptReport)
 
 
'display the Report            
 
Dim instance As New InstanceReportSource()            
 
instance.ReportDocument = rptMSVS            
 
Session("Report") = instance            
 
Response.Redirect("rvReportViewer.aspx")

 

 

'ReportViewer page code behind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
 
            Dim hshTable As New Hashtable()
            Dim rptProcessor As New Telerik.Reporting.Processing.ReportProcessor()
            Dim result As Telerik.Reporting.Processing.RenderingResult = rptProcessor.RenderReport("XLS", Session("Report"), hshTable)
 
            rptViewer.ReportSource = Session("Report") 'instance
            rptViewer.DataBind()
 
        End If
    End Sub

Hope this helps.

0
Stef
Telerik team
answered on 31 Mar 2017, 02:47 PM
Hi Mark,

Based on the provided code snippet:
  1. You create a report instance(rptReport) of type rptMSVS;
  2. There is a SubReport, Table and TextBox items in that report instance which are with public modifier in order to access it the way it is written in code;
  3. You create a another report instance (rptSummary) that is used by the SubReport item;
  4. Then you create a ReportBook instance (reportBook) and you add the report instances mentioned in point 1 and point 3;
  5. Then it looks like you have another ReportBook instance which name duplicates the name of the type of the report created in point 1 - rptMSVS;
  6. The ReportBook instance of point 5 displays the report of point1 and it is visualized by the ReportViewer control.

In the above code, we recommend you to change the following:
  • Check which report and ReportBook instances are needed and remove the rest;
  • To get a nested data item from the report, use the Find method on the report's Items collection e.g.:
    Dim reportInstace As New MyReportType
    'get a TextBox item by name
    Dim txtb1 = DirectCast(reportInstance.Items.Find("textBox1", True)(0), Telerik.Reporting.TextBox)
    'get a nested Table item by name
    Dim table1= DirectCast(reportInstance.Items.Find("Table1", True)(0), Telerik.Reporting.Table)
    'get a SubReport item
    Dim subReportItem1= DirectCast(reportInstance.Items.Find("SubReport1", True)(0), Telerik.Reporting.SubReport)
    subReportItem1.Visible=False
    ......
    You can also remove the subReportItem1 from the report instance's Items collection.

If the above changes do not help you to resolve the issue, please open a support ticket and send us a demo project that illustrates the settings and reproduces the reported problem. This will allow us to understand better the created reports and the issue.

Regards,
Stef
Telerik by Progress
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
0
Mark
Top achievements
Rank 1
answered on 31 Mar 2017, 02:51 PM
Thanks, that did the trick.
Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
Stef
Telerik team
Mark
Top achievements
Rank 1
Share this question
or