MVC, HTML5 Report Viewer and ObjectDataSource

2 posts, 0 answers
  1. Humberto
    Humberto avatar
    1 posts
    Member since:
    Jan 2012

    Posted 22 Apr 2016 Link to this post

    Hello. I have created a report using the Standalone Designer. I am able to display the report in an MVC view using an HTML5 Report Viewer but I have not been able to display data using ObjectDataSource and an in-memory business object.

    I found this post by Stef on the forums (16 Jul 2014):
    “The HTML5 Report Viewer and the Reporting REST service does not use the MVC concept. Thus if you have a model containing data or other information required in your reports, you need to implement a logic to access that model in the reports' controller e.g. to store the data and access it by key in the service's resolver, or to modify the reports to use such data source component, that wraps a data retrieval method having access to that model.”

    ¿Could you please elaborate how this is done?

    The post continues: “… A demo of a report that uses a custom data retrieval method is available in the local examples under C:\Program Files (x86)\Telerik\Reporting Q2 2014\Examples\CSharp\ReportLibrary\DataBinding. The ListBoundReport uses an ObjectDataSource to retrieve data from a custom business object. This business object can be modified anywhere in the application, when the report is requested its ObjectDataSource will search for the assigned data retrieval method and will get the data.”

    I have reviewed the example but I still don’t get how it works. The objectDataSource1 has DataSource assigned but no DataMember assigned. Shouldn’t the DataMember property contain the data retrieval method name mentioned in Stef’s post to get the data? In any case, how does it know what instance of the class should be used to retrieve the data from? Let’s say I have a Product class and there are 2 instances of this class: productA and productB, How do I tell ObjectDataSource to use product for instance?

    Thank you very much in advanced,

  2. Stef
    Stef avatar
    3611 posts

    Posted 25 Apr 2016 Link to this post

    Hi Humberto,

    The ObjectDataSource allows you to specify data in a declarative manner, where the ObjectDataSource.DataSource property gets the type of a class or its string description (assembly qualified name). And the ObjectDatasource.DataMember property can set or can be left unassigned - it points a specific method that will be executed.
    At run-time the reporting engine will create an instance of the specified class by using its default constructor via System.Reflection, and if a method is set as DataMember it will be executed on behalf of the created instance.

    To use an ObjectDataSource component in the Standalone Report Designer tool, you will have to build the data-retrieval logic in an external assembly that extends the tool - Extending Report Designer (tutorials are linked at the bottom of the help article).

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top