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

Displaying programmatically created report in html viewer

4 Answers 178 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Iron
Iron
Iron
Al asked on 05 Sep 2016, 02:23 PM

Hi,

I have a custom resolver working with my html report viewer to display trdx's just fine. Some reports though are not trdx though so I will create these purely in code (in my resolver?) and pass the report to the viewer. I have tried the code below and it seems to work but I just need to confirm that I am doing it the correct way?

ie. is it correct to return a report object instance from the custom resolver?

public class MyResolver : IReportResolver
{
    public Telerik.Reporting.ReportSource Resolve(string report)
    {
        Report rpt = new Report();
 
        ObjectDataSource ods = new ObjectDataSource();
        ods.DataSource = GetSomeData();
        rpt.DataSource = ods;
     
    /*
    ...code to set up report items...
    */
             
        return rpt;
}
 }

 

 

4 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 06 Sep 2016, 02:41 PM
Hello Al,

IReportResolver needs to return a valid report source object. Thus, my suggestion is to wrap the report object into one of the available report sources (for example InstanceReportSource) and return it in Resolve method.
An example of custom resolver implementation is provided here.

Note, that the IReportResolver.Resolve(String) method will be called each time when the Reporting engine needs the report source. This can happen serveral times until the report document is completely rendered. It is important that when the method is invoked multiple times it returns exactly the same report source for a given value of the passed string argument.


Regards,
Katia
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
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 06 Sep 2016, 03:07 PM

Thanks Katia,

My approach seems to work just fine though? ie. just returning the report object as above seems to be ok.

0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 07 Sep 2016, 08:42 AM

Hi Katia,

After reading up on this it seems that the conversion from Report to ReportSource is obsolete (although it does still work as I mentioned). I am using this code in my custom resolver (which also works), is this what you meant?

Report rpt = GetReport();
InstanceReportSource irs = new InstanceReportSource();
irs.ReportDocument = rpt;
return irs;

0
Katia
Telerik team
answered on 07 Sep 2016, 10:34 AM
Hello Al,

That is correct, using the Report object instead of ReportSource will result in warnings regarding the obsolete code.

The code provided in your last post is valid, you can use it to wrap the report's instance into InstanceReportSource and return it in Resolve() method.


Regards,
Katia
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
Tags
General Discussions
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Katia
Telerik team
Al
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or