Can i please get some advice on how to incorporate existing reports in to my ASP.Net MVC application?
The are in a separate project inside the same solution and were created with the telerik report designer for visual studio.
The reports run and can be visualised without any issue, however i have no idea how to display these same reports inside of a view in my main application.
I have looked at the existing documentation and some of the examples avaiable but i cannot achive the same results.
Some examples stated that i need to have an instance of report server running. other examples state that all i need is to add a report viewer, I tried to add one to my app however the report viwer cannot find my reports because it looks for files of extention TRDX which are not the same as my reports, in fact the report server also seems to use TRDX files.
So can i please get som indication into how to get my reports displaying in my app (based on ASP.Net MVC .net 4.5 (Razor)) . And if needed how can the existing reports be converted to the TRDX format?
Links to a walkthrough example would be greatly appreciated.
5 Answers, 1 is accepted
In an MVC application you can use the MVC wrapper of the HTML5 Viewer - How To: Use HTML5 ASP.NET MVC Report Viewer in an application. The HTML5 Viewer requires a running instance of the Reporting REST service. Reports are processed and rendered server-side, on the machine where the Reporting REST service is running.
A note, the Reporting REST service should not be mistaken with Telerik Report Server.
- The viewer has a client-side ReportSource, from which we extract the string description of the report (relative path to a TRDP|TRDX file), the assembly qualified name of a report class (<namespace>.<report_class>, <assembly_name>) or custom string (almost anything can be included with respect to REST limitations for used characters and size of the message).
- The reports string description is submitted to the server and it is handled by the Reporting REST service's Resolver. The service's default resolvers can handle a relative path to a TRDP|TRDX files or an assembly qualified name of a report class. Anything else requires you to create a custom resolver that returns a server-side ReportSource object on its own.
- Once the Report resolver returns the server-side ReportSource object, the viewer submits the Parameters collection of its client-side ReportSource. This Parameters collection is applied as the server-side's ReportSource.Parameters collection.
- Next, the reporting engine starts processing the report, means the report events fire, expressions are evaluated. At that moment the server-side ReportSource.Parameters collection is mapped to the report's ReportParameters collection - where Name properties (case sensitive) are the same, values are set for the report parameters.
- Finally, the report is rendered and paged in the requested format (HTML for web preview, PDF for export and etc.), and the content id returned to the client(viewer).
The attached video illustrates how to add the MVC wrapper in an application with the VS item template. It can be previewed in IE browser. For MVC5 projects you will need to run VS Nuget Package Manager> Updates> Update All in order binding redirects to be added for the used WebAPI libraries.
Telerik by Progress
Thansk a lot for your reply, and especially for the video it was really helpful. However, even though i managed to obtain the same results in a sample application it took me a long while before i managed to add a report viwer in my application.
Since it took me a long while to get it up and running i'm just leaving here some pointers in case someone has the same issue on the future.
When i followed the steps on the tutorial and went to add a report viewer
Add > New Item > Telerik MVC Report Viewer R3 2016; then i selected Embeded > Next and it took me to the following screen as it was shown on the video however when i selected "Existing report definition" my project with the reports would not be listed under "Type report definition created in Visual Studio" as shown on the video at (1:42).
After countless and countless hours of struggle i realised that the issue is that my report project was not on the root folder of the solution. The report viewer wizard only recogises the project if its located on the root of the solution. (E.g /SolutionFolder/ReportProjectFolder/report1.cs). If there is another folder between the SolutionFolder and the ReportProjectFolder (E.g /SolutionFolder/Presentation/ReportProjectFolder/report1.cs) then the report viewer wizard does not recognise the project.
I'm not sure if i missed something, if its a bug or if its the intended behaviour however its present on the documentation and its and detail that is extremely dificult to figure out.
I would suggest that you guys have a look at it or at least update the documentation. Anyway i hope this post is helpfult to someone else.
This is not an expected behavior to my knowledge.
Please check the attached video in IE browser, and let us know if these are the steps to reproduce the problem. If yes, I will forward the case to our development team for further investigation.
On a side note, adding manually a reference to the reports project resolves the problem. For some reason the types browsing cannot find the report's class in the solution. In our test any following project manages to load the reports project.
Telerik by Progress
The problem mentioned in my previous post is already in development. If issues are related, a fix can be expected in the official R1 2017 in the middle of January.
Telerik by Progress
Thanks for the feedback. When i was busy with that issue, I also tried to add the reference manually to the web project as you have shown in the video above, but did not achieve the same outcome, i probably did not rebuild the project after i did added the reference.
Anyway, I'm glad to hear that you guys are looking into it.