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

Telerik Reports with MVC 4 report source

2 Answers 326 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rory
Top achievements
Rank 1
Rory asked on 03 Dec 2013, 07:11 PM
Hello, i am trying to setup a simple example of reports on our MVC 4 application but i am having difficulty in referencing my report.

i have setup my view and controller as described in these articles:
http://www.telerik.com/help/reporting/html5-report-viewer-embedding.html
http://www.telerik.com/help/reporting/telerik-reporting-rest-implementing-http-service.html

I do NOT want to use a trdx file to reference my report, i just want to be able to use the Report.cs file as we would have in the past.  None of the documentation talks about using the .cs report files anymore, which is somewhat confusing.

According to this post, we still can use .cs report files.

When i try to view the report, the viewer is displayed but there is just a message saying 'Not Found'.  So what is the correct way to reference a .cs report?

Currently my viewer is setup as:
        $("#reportViewer1")
            .telerik_ReportViewer({
                serviceUrl: "/api/reports/",
                templateUrl: '../Content/ReportViewer/templates/telerikReportViewerTemplate.html',
                reportSource: { report: 'new Telerik.Reporting.TypeReportSource() { TypeName = "Application.Reports.TestReport, Application" }' },
                scale: 1.0
            });

Application is the main assembly.
Reports is the folder where my reports are stored, in the Application project.  
TestReport is the .cs report file.

what am i missing? please n thanks.

Edit: there is also a javascript error when the report is displayed that says:
Failed to load resource:      http://localhost:53661/api/reports/clients/115240-ff1a/parameters
I assume its related to the fact that it cant find the report but thats about all i can figure out from that.

2 Answers, 1 is accepted

Sort by
0
Rory
Top achievements
Rank 1
answered on 03 Dec 2013, 09:26 PM
i think i found the answer despite the confusing documentation.

i ended up using the extension method as described here since the other ways would not work for me and this seems to provide more customization.

@{
    var typeReportSource = new TypeReportSource() { TypeName = "Application.Reports.TestReport, Application" };
    typeReportSource.Parameters.Add("OrderNumber", Model.SelectedInvoice);  
}
@(
    Html.TelerikReporting().ReportViewer()
    .Id("reportViewer1")
    .ServiceUrl("/api/reports/")
    .TemplateUrl("../Content/ReportViewer/templates/telerikReportViewerTemplate.html")
    .ReportSource(typeReportSource)           
    .ViewMode(Telerik.ReportViewer.Mvc.ViewModes.PRINT_PREVIEW)
    .ScaleMode(Telerik.ReportViewer.Mvc.ScaleModes.SPECIFIC)
    .Scale(1.0)
    .PersistSession(true)
 )

0
Peter
Telerik team
answered on 06 Dec 2013, 02:00 PM
Hi Rory,

Thank you for your feedback. We will consider adding example with TypeReportSource. In the meantime check out the MVC demo that came with your Telerik Reporting installation for which we use TypeReportSource as shown in the following code snippet:

@(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer1")
        .ServiceUrl("api/reports/")
        .TemplateUrl("ReportViewer/templates/telerikReportViewerTemplate.html")
        .ReportSource(new TypeReportSource() { TypeName = "Telerik.Reporting.Examples.CSharp.ReportCatalog, CSharp.ReportLibrary" })
        .ViewMode(ViewModes.INTERACTIVE)
        .ScaleMode(ScaleModes.SPECIFIC)
        .Scale(1.0)
        .PersistSession(true)
)

Regards,
Peter
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Rory
Top achievements
Rank 1
Answers by
Rory
Top achievements
Rank 1
Peter
Telerik team
Share this question
or