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

InstanceReportSource Not Working, Viewers says No Report.

1 Answer 339 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aubrey Ivan
Top achievements
Rank 1
Aubrey Ivan asked on 31 Oct 2019, 06:14 AM

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"


1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 04 Nov 2019, 04:59 PM

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
Tags
General Discussions
Asked by
Aubrey Ivan
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or