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

Load Report from Cloud and pass parameters to subReports

1 Answer 230 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fernando
Top achievements
Rank 1
Fernando asked on 27 Jun 2017, 06:30 PM

Hi, we are developing a asp.net mvc application and we are using the Telerik Reporting and HTML5 Viewer (and javascript). Everything works fine when we use our "trdp" or "trdx" report files on the file system and we get the report on the page access a database and showing some data. 

Now, we are changing how we store the files on the system and we are going to a cloud storage environtment where all files will be on the cloud, including the trpd report files. It also could be stored on the database. We are using the InstanceReportSource to get the report object as byte array (from cloud or database) like this:

// get the stream for trdp report file
var reportStream = GetReportStreamFromCloud(...);
 
var reportDocument = (Telerik.Reporting.Report) reportPackager.UnpackageDocument(reportStream);
 
// check for subReports to replace it dynamically (code bellow here..)
 
var instanceReport = new InstanceReportSource() {ReportDocument = reportDocument};
 
return instanceReport;


It works fine when it is a simple report without subReports. The problem is when we have subReports and we try to set it dynamically as a byte array using InstanceReportSource and this SubReport has parameters (independently if it comes from main Data Source or from main Report Parameters). The code bellow is how we set the subReport:

foreach (var sections in reportDocument.Items.Where(x => x is DetailSection || x is GroupSection))
{
    foreach (var item in sections.Items.Where(x => x is SubReport))
    {      
        var subReport = (SubReport) item;                       
 
        // get the Stream for trdp subreport file.
        var subReportStream = GetReportStreamFromCloud(...);
         
        // unpack the report Stream
        var subReportDocument = (Telerik.Reporting.Report) reportPackager.UnpackageDocument(subReportStream);
 
        var instanceSubReport = new InstanceReportSource() {ReportDocument = subReportDocument};
         
        subReport.ReportSource = instanceSubReport;
    }
}

How can we pass the parameters to the subReport dynamically?

Thank you.

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 28 Jun 2017, 04:32 PM
Hi Fernando,

You need to transfer the settings of the SubReport item's ReportSource to the newly created report source object e.g.:
instanceSubReport.Parameters.AddRange(subReport.ReportSource .Parameters);
subReport.ReportSource = instanceSubReport;

I hope this helps.

Regards,
Stef
Progress 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
Fernando
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or