This is a migrated thread and some comments may be shown as answers.

Using ObjectDataSource With Non-Static Methods?

1 Answer 234 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 07 Jan 2015, 01:42 PM
I'm using the HTML5 report viewer with an ObjectDataSource.  The model referenced by the ObjectDataSource is populated by a logic call from a service that is injected in my MVC reports controller.  Unless the model exposes a static method to get the data for the report, no data is returned in the report (all fields are empty).  However, when the method is static, two different clients accessing two different sets of data (different filter parameters in the controller), are stepping on each other, and the wrong report is rendered for the second user.  For example, if I log in to my application from two different browsers (Chrome and FF, for example), load the report with different data filter parameters in each browser (which should display two different reports), and then refresh both browsers simultaneously, both render the same report because of the static method.  Obviously, this is a big problem for a multi-user web application - it is assumed that a report should be accessible by many users that are viewing different data.

How can an ObjectDataSource be used with non-static methods?  Or, assuming you have a business logic layer call that returns a collection of objects to feed a Telerik report, how should an HTML5 Telerik report be architected for multi-user access, where the same report can be rendered simultaneously for multiple users accessing different data (invoices for example)?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 08 Jan 2015, 09:11 AM
Hello Ed,

You can use a service to supply data for reports, where the data retrieval method operating with the service is wrapped by an ObjectDataSource. Consider the example in Connecting Telerik Reporting to OData feeds.

Thus you will just have to pass proper parameters to control the data retrieval and display the report in a viewer.


In general, the HTML5 Report Viewer is a client-side widget served only by a running Reporting REST service, which is dedicated to display already created reports. It is the service that manages the report state and resources.

Details how to add the viewer via template are available in the HTML5 Report Viewer Quickstart article


How the viewer(client)-service pair works:

Basically, the client (viewer) sends string description of the requested report (the viewer's reportSource.report value) to the service, and depending on the report resolvers in the service's CreateReportResolver method this string description will be resolved to a report source object.
By default we provide ReportFileResolver and ReportTypeResolver. You can also create your own report resolvers as in the example in the How To: Implement a Custom Report Resolver article.

Depending on how the application will be hosted, you can use the corresponding cache storage for the service - REST Service storage. If the service will be hosted separately, and will use a different domain you may need to enable CORS to allow the communication between the clients(viewers) and the service.


I hope the provided information helps you.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Ed
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or