I'm trying to integrate Telerik reporting functionality into Orchard. I've created a custom module that serves up a view containing the ReportViewer syntax, as below:
<div id="reportViewer1" class="k-widget">
loading...
</div>
<script type="text/javascript">
$("#reportViewer1")
.telerik_ReportViewer({
serviceUrl: "/api/CustomReports/reports",
templateUrl: "/Modules/CustomReports/Reports/templates/telerikReportViewerTemplate.html",
reportSource: {
report: "~/Modules/CustomReports/Reports/PlayerCurrentContract.trdx",
parameters: {
/*ReportYear: "2003"*/
}
},
viewMode: "ViewModes.INTERACTIVE",
scaleMode: "ScaleModes.SPECIFIC",
scale: "1.0"
});
</script>
The module attempts to implement the Telerik REST Api in a controller, indentical to the ReportsController in this guide.
My problem is that the ReportViewer's requests to the controller aren't getting through in most cases (verified using Fiddler that the requests are formatted correctly). So for example:
http://localhost:30301/api/CustomReports/reports/clients/ // Works, response contains a client ID
http://localhost:30301/api/CustomReports/reports/clients/124902-a308/parameters // returns a 404
I'm almost certain this is a routing issue, but I'm not sure how to solve it. Orchard doesn't easily give you access to a HttpContext for the ReportsControllerConfiguration.RegisterRoutes() call, so I set up a little hack in Orchard.WebApi.DefaultOrchardWebApiHttpHttpControllerActivator class:
private bool _reportsRoutesRegistered;
public IHttpController Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) {
if (!_reportsRoutesRegistered) {
_reportsRoutesRegistered = true;
_configuration.Routes.MapHttpRoute(
name: "CustomReportsApi",
routeTemplate: "api/{controller}/reports/{id}",
defaults: new { id = RouteParameter.Optional }
);
ReportsControllerConfiguration.RegisterRoutes(_configuration);
}
...
I don't seem to get any exceptions doing this, but obviously something isn't working correctly. I understand that this is a fairly obscure issue (not many posts about using Telerik Reporting in Orchard on the web), but I would greatly appreciate any assistance. Thanks!
<div id="reportViewer1" class="k-widget">
loading...
</div>
<script type="text/javascript">
$("#reportViewer1")
.telerik_ReportViewer({
serviceUrl: "/api/CustomReports/reports",
templateUrl: "/Modules/CustomReports/Reports/templates/telerikReportViewerTemplate.html",
reportSource: {
report: "~/Modules/CustomReports/Reports/PlayerCurrentContract.trdx",
parameters: {
/*ReportYear: "2003"*/
}
},
viewMode: "ViewModes.INTERACTIVE",
scaleMode: "ScaleModes.SPECIFIC",
scale: "1.0"
});
</script>
The module attempts to implement the Telerik REST Api in a controller, indentical to the ReportsController in this guide.
My problem is that the ReportViewer's requests to the controller aren't getting through in most cases (verified using Fiddler that the requests are formatted correctly). So for example:
http://localhost:30301/api/CustomReports/reports/clients/ // Works, response contains a client ID
http://localhost:30301/api/CustomReports/reports/clients/124902-a308/parameters // returns a 404
I'm almost certain this is a routing issue, but I'm not sure how to solve it. Orchard doesn't easily give you access to a HttpContext for the ReportsControllerConfiguration.RegisterRoutes() call, so I set up a little hack in Orchard.WebApi.DefaultOrchardWebApiHttpHttpControllerActivator class:
private bool _reportsRoutesRegistered;
public IHttpController Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) {
if (!_reportsRoutesRegistered) {
_reportsRoutesRegistered = true;
_configuration.Routes.MapHttpRoute(
name: "CustomReportsApi",
routeTemplate: "api/{controller}/reports/{id}",
defaults: new { id = RouteParameter.Optional }
);
ReportsControllerConfiguration.RegisterRoutes(_configuration);
}
...
I don't seem to get any exceptions doing this, but obviously something isn't working correctly. I understand that this is a fairly obscure issue (not many posts about using Telerik Reporting in Orchard on the web), but I would greatly appreciate any assistance. Thanks!