
5 Answers, 1 is accepted
Hi Aubrey Ivan,
Our Html5-based Viewers, including the MVC Viewer, use REST Service to deliver reports - check HTML5 Report Viewer and Reporting REST services. All that is related to processing and rendering the report happens in the REST Service, where the reporting engine runs. If you would like to pass the data to the report from the client, it will be necessary to pass it either directly to the report definition, or to the REST Service, where to instantiate the report and assign it data.
For the first approach that we recommend, you may expose the data in Web service and use the WebServiceDataSource to get it directly from the report.
Alternatively, you may place the data in a temporary repository from the viewer action, and then get it in the Report. For example, save it in CSV text file and use CsvDataSource.
In the approach with instantiating the report, you need to use Custom Report Resolver in the REST Service. You may pass the necessary data in the 'report' argument of the Resolve method. You should serialize the data and send it as part of the ReportSource->Report property of the viewer, which will be received as the string 'report'.
I have attached a sample MVC project demonstrating the approach. I have hard-coded some data in the Home Controller for simplicity as getting the data from a View is not related to the Reporting tool.
Regards,
Todor
Progress Telerik

Hi Todor,
Your example helped me out a lot, I just have one more question, what if my data is dynamic and I do not know which type of object I am expecting, how do I handle that inside the custom resolver? Do I create a multiple custom-resolver? or do I make a if-else case statements inside the custom resolver and DeserializeObject the data depending on the if-else statements inside the custom resolver
I have multiple classes which would be my data, should I use only 1 custom resolver and determine which object it would be deserealized from, inside the customResolver?

If possible I want to re-use the report-viewer by passing a string reportSource to it and handle the data inside the custom resolver, and I also want to re-use the custom-resolver. I would like to deserialize multiple classes inside the custom resolver, how do I do that?
Regards,
Ivan
Hi Ivan,
It is better if you deserialize the data conditionally, inside a single Custom Report Resolver. For example, you may concatenate a key indicating which data model should be used for deserializing in the report string and use if-else or switch-case statements to control the workflow.
Note that you have other options to transfer the data to the report, e.g. WebServiceDataSource that gets the data from a custom Web Service.
Regards,
Todor
Progress Telerik

Hi Todor,
Yes, tha'ts what I intend to do. I will pass the report and data as string and deserialize the data into object depending on the report that was also passed.
Thanks,
Ivan