Hi All,
I wanted to pass the viewmodel to report viewer in Reportview.cshiml. but I havn't got any such examples . always seeing the example on to bind the datasource in the ReportController . binding data source from report controller working as expected but looking for help on the view model binding in Razor Syntax.
My Cshtml Code
@using ReportingLibrary
@using Telerik.ReportViewer.Mvc
@using CPGUX.ProjectManagement.Core.Entities
@using CPGUX.Utility.Helpers
@model IEnumerable<ProjectDetails>
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl(Url.Content("~/api/reports/"))
.TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-FA.html"))
.ReportSource(new Telerik.Reporting.TypeReportSource() { TypeName = typeof(CPGUX.ReportingLibrary.AllProjectsByUser).AssemblyQualifiedName })
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.Specific)
.Scale(1.0)
.PersistSession(false)
.PrintMode(PrintMode.AutoSelect)
.Deferred()
)
ReportController.cs
public Telerik.Reporting.ReportSource Resolve(string report)
{
Report reportInstance = null;
if (report.Contains("AllProjectsByUser"))
{
string result = _projectController.GetProjectNumberSession();// new ProjectController().GetProjectNumberSession();
reportInstance = new AllProjectsByUser();
reportInstance.DataSource = _projectService.FindProjectsByUser(IIdentityUser, 100, 0); // don't want to call instead of binding should haven in viewer itself
}
}