InstanceReportSource Not Working, Viewers says No Report.

2 posts, 0 answers
  1. Aubrey Ivan
    Aubrey Ivan avatar
    25 posts
    Member since:
    Oct 2019

    Posted 31 Oct Link to this post

    Here is my controller which I am using a instance report

     

            public ActionResult Index()
            {
                //===============================================================================
                var objDts = new ObjectDataSource();
                objDts.DataSource = new Sample();
                objDts.DataMember = "GetSample";

                var orgSampleReport = new OrganisationSample();
                orgSampleReport.DataSource = objDts;

                var reportSource = new Telerik.Reporting.InstanceReportSource();
                reportSource.ReportDocument = orgSampleReport;

                return View(reportSource);
                //===============================================================================
            }

     

    and here is the logic that I am puling from 

        [DataObject]
        public class Sample
        {
            public int Id { get; set; }
            public string Name { get; set; }
            
            public Sample GetSample()
            {
                var sample = new Sample
                {
                    Id = 1,
                    Name = "Sample 1"
                };

                return sample;
            }
        }

     

    whenever I run the program and go to the report viewers it shows "No Report"


  2. Todor
    Admin
    Todor avatar
    397 posts

    Posted 04 Nov Link to this post

    Hi Aubrey Ivan,

    The Html5 Viewer uses Telerik Reporting REST Service to deliver reports - check HTML5 Report Viewer and Reporting REST services. The client-side reportSource is a property of the viewer that contains a report identifier and collection with parameter values. It cannot contain a report instance. The message is received because InstaceReportSource is not supported by the Html5 Viewer (including its MVC wrapper).

    If you need to instantiate a report, for example, in order to set its DataSource, you need to do this in a Custom Report Resolver in the REST Service. The Resolve() method of the resolver will receive as an argument the reportSource.report property. With the MvcViewer in the case of TypeReportSource, this will be the assembly qualified name of the report class, i.e. the TypeName. You need to instantiate the report based on this information and set its data source as required. Then you may return the modified report wrapped in an InstanceReportSource from the Resolve method - it will be passed to the Reporting engine. Hence, the logic for assigning a data source to the Report should be moved to the Resolve method of a custom report resolver.

    Regards,
    Todor
    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
Back to Top