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

Telerik Report MVC and webapi (Telerik VS Report Designer)

1 Answer 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
faris
Top achievements
Rank 1
faris asked on 09 Jul 2014, 02:50 AM
im new in telerik report. my project is, i want webapi call Report Library that i created using telerik VS report designer). after follow the demo, i success for calling standalone report. but now i want to call from report library

.here is my code

in view
@( Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
 .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
.ReportSource(new UriReportSource() { Uri = "User.trdx" })
.ViewMode(ViewModes.INTERACTIVE)
.ScaleMode(ScaleModes.SPECIFIC)
.Scale(1.0) )


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

i have create a Project for ReportLibrary and class UserReport.cs using VS ReportDesigner. i need to call UserReport in WebApi or View? and how to call?

firstly i need to change

.ReportSource(new UriReportSource() { Uri = "User.trdx" }

to 
.ReportSource(new TypeReportSource() { TypeName ="Class1.User, Class" })

how about in ReportsController?

i no need to use ReportFileResolver right?

thank you so much

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 11 Jul 2014, 01:38 PM
Hello Faris,

You only need to change the used report source type from UriReportSource to TypeReportSource. No changes are needed in the ReportsController as it can handle both report source types.

When using TypeReportSource it is recommended to use the Type.AssemblyQualifiedName property instead of writing the string manually i.e.:
.ReportSource(new TypeReportSource() { TypeName = typeof(ReportNamespace.UserReport).AssemblyQualifiedName })

Regards,
Nasko
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
faris
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or