I have a Visual Studio solution that contains two different projects. One is a class library that I used to create a simple report that lists users and some of their standard info. The DataSource for the report is a class with some hard coded data as a JSON string:
using
Newtonsoft.Json;
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
namespace
AdventureWorksReports {
public
class
UsersObject {
public
string
UserId {
get
;
set
; }
public
string
LastName {
get
;
set
; }
public
string
FirstName {
get
;
set
; }
public
DateTime? LastLogin {
get
;
set
; }
}
[DataObject]
public
class
Users {
[DataObjectMethod(DataObjectMethodType.Select)]
public
static
IEnumerable<UsersObject> GetUsers() {
var json = <LONG-JSON-STRING>;
return
JsonConvert.DeserializeObject<List<UsersObject>>(json);
}
}
}
Using
the report designer I have a simple report (UsersList.cs [Design] in
the AdventureWorksReports project) that uses the above GetUsers() method
for populating the report. Nothing fancy, but it's displaying the data.
I'm
having no success getting anything to display in a second project in
the solution. This second project is a .NET MVC web application. I have a
ReportController that inherits from ApiController to serve as the
reporting server that does return the same JSON that works in the stand
alone report above:
using
AdventureWorksReports;
using
System.Collections.Generic;
using
System.Web.Http;
namespace
WebApp.Controllers {
public
class
ReportController : ApiController {
[HttpPost]
public
IEnumerable<UsersObject> Post() {
var users = Users.GetUsers();
return
users;
}
}
}
I feel like I have no idea how to set up the ReportViewer control in razor. I have the following, but it is obviously lacking:
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl("~/api/report/")
.TemplateUrl("~/ReportViewer/templates/telerikReportViewerTemplate.html")
.ReportSource()
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.Specific)
.Scale(1.0)
.PersistSession(false)
.EnableAccessibility(false)
.Deferred()
)
Can anybody give me some clues as to what is missing at this point? It seems like none of the tutorials I've found address the situation as I'm trying to build it.
thanks
-Josh