Displaying programmatically created report in html viewer

5 posts, 0 answers
  1. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 05 Sep Link to this post

    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;
    }
     }

     

     

  2. Katia
    Admin
    Katia avatar
    308 posts

    Posted 06 Sep Link to this post

    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
  3. DevCraft banner
  4. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 06 Sep in reply to Katia Link to this post

    Thanks Katia,

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

  5. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 07 Sep in reply to Al Link to this post

    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;

  6. Katia
    Admin
    Katia avatar
    308 posts

    Posted 07 Sep Link to this post

    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
Back to Top
DevCraft banner