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

Telerik reports with MVC 4

3 Answers 231 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chamara
Top achievements
Rank 1
Chamara asked on 15 Nov 2013, 07:42 AM
I'm trying to create a simple report with telerik reporting and ASP.NET MVC 4. I have several questions

I have created a sample report by binding to a sql datasource.

my report name is "Report2.cs" but i'm confused about .trdx report (why should i create a .trdx report)?

when trying to bind  the report to report viewer i use the below code.

@{
    ViewBag.Title = "reportview";
    Layout = "~/Views/Shared/_mainView.cshtml";
}

@section styles
{

    <link href="~/Content/ReportViewer/styles/ReportViewer-7.2.13.1016.css" rel="stylesheet" />
    <style>
        #reportViewer1
        {
            position: absolute;
            left: 5px;
            right: 5px;
            top: 5px;
            bottom: 5px;
            overflow: hidden;
        }
    </style>
}

@section scripts
{
    <link href="~/Content/kendo/2013.2.716/kendo.common.min.css" rel="stylesheet" />
    <link href="~/Content/kendo/2013.2.716/kendo.blueopal.min.css" rel="stylesheet" />
    <script src="~/Scripts/kendo/2013.2.716/kendo.all.min.js"></script>

    <link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
    <script src="~/Content/ReportViewer/js/ReportViewer-7.2.13.1016.js"></script>
    
}

@(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer1")
        .TemplateUrl("/Content/ReportViewer/templates/telerikReportViewerTemplate.html")
        .ReportSource(new Telerik.Reporting.TypeReportSource() { TypeName = "MvcReportApplication.MyReport.Report2" })
        .ViewMode(Telerik.ReportViewer.Mvc.ViewModes.INTERACTIVE)
        .ScaleMode(Telerik.ReportViewer.Mvc.ScaleModes.SPECIFIC)
        .Scale(1.0)
        .PersistSession(true)
)

report is not displayed and i get the below error in console

Uncaught TypeError: Cannot call method 'replace' of undefined

3 Answers, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 19 Nov 2013, 04:12 PM
Hi Chamara,

In the TypeName you should also provide the assembly name, like this: "MvcReportApplication.MyReport.Report2, MvcReportApplication". Also you will need to specify the service url, like this:
.ServiceUrl("api/reports/")

Regarding the trdx - you can create trdx report with the Report Designer, which works outside of Visual Studio. The trdx report is simply the serialized (xml) definition of the report. Since it is a single file and does not require VS if you have users that need to create reports it will fit better in your scenario. For more information about the Report Designer please check this help article and the related subarticles.

Regards,
IvanY
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.

0
faris
Top achievements
Rank 1
answered on 09 Jul 2014, 02:34 AM
i cannot find why i need to create 2 file? .trdx and Report2.cs?
can i call Report2.cs withour call .trdx in webapi?

public class Reports1Controller : ReportsControllerBase<br>{<br>    protected override IReportResolver CreateReportResolver()<br>    {<br>        var appPath = HttpContext.Current.Server.MapPath("~/Reports");<br><br>        return new ReportFileResolver(appPath)<br>            .AddFallbackResolver(new ReportTypeResolver());<br>    }<br><br>    protected override ICache CreateCache()<br>    {<br>        return CacheFactory.CreateFileCache();<br>    }<br>}


0
Stef
Telerik team
answered on 11 Jul 2014, 08:54 AM
Hello Faris,

With the given ReportsControllerBase implementation you can pass path to TRDX reports or the assembly qualified name of a report. There are the two default resolvers, where if the first fails to resolve successfully the passed report description, the second resolver will be called.

For more details check this forum thread. Yo can also check the local demos installed by default under C:\Program Files (x86)\Telerik\Reporting Q2 2014\Examples\CSharp.


I hope this information helps you.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Chamara
Top achievements
Rank 1
Answers by
IvanY
Telerik team
faris
Top achievements
Rank 1
Stef
Telerik team
Share this question
or