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

Multiple reports sharing the same ObjectDataSource.DataSource instance

2 Answers 153 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 15 May 2018, 06:37 PM
I’m using a ReportBook to display 2 different reports.  Both reports can also run independently from the other.  The second report is a recap of the first report, which means the data for the second report relies on the same data generated for the first report.

The ObjectDataSource.DataSource of both reports are assigned the same Type ( typeof(MyDataObject) ), but they are assigned different DataMembers.  MyFirstReport calls MyDataObject.GetRecords() and MySecondReport calls MyDataObject.GetRecapRecords().

When they are run together in the ReportBook, both reports are creating a unique instance of MyDataObject.  In other words, there are two instances of MyDataObject created.  Since both reports use the same DataSource Type, is there any way for both reports to share only one instance of MyDataObject when they are run from the ReportBook?

2 Answers, 1 is accepted

Sort by
0
Keith
Top achievements
Rank 1
answered on 17 May 2018, 08:01 PM

And I have a related follow-up question.

The second report may or may not have data to display depending on what records are returned as data for the first report.  Is there any way to configure the second report or the ReportBook to not display the second report when there is no data to display?

I realize I can display a TextBox with the Value of “No records returned” in the header of the second report if no results are returned, but I would prefer to not display the report at all.

I also realize I can skip adding the second report to the ReportBook if I generate the results beforehand.  But since I don’t want to generate the results a second time for the report itself, that would mean implementing a cache of some sort.

However, it would be most preferable if there was an IgnoreEmptyReports flag I could set and let the report or ReportBook do all the work.

 


0
Todor
Telerik team
answered on 18 May 2018, 08:57 AM
Hi Keith,

Each data source is independent on the others. We use reflection to find and instantiate each data providing object.
There is no built-in functionality to tell two/several data sources to use the same instance of the data providing object.
Consider using Singleton design pattern to assure that only one instance of the object will be created.

Currently the ReportBook does not have property as IgnoreEmptyReports, hence your second requirement is not directly achievable and it would be necessary to use a workaround. Skip adding the second report when it does not receive data is a suitable solution.

Note that there is an increasing demand for the the desired ReportBook functionality from our community.
I suggest to vote for the corresponding feature request in our feedback portal - Do not render blank reports in reportBook.

Regards,
Todor
Progress Telerik
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
Tags
General Discussions
Asked by
Keith
Top achievements
Rank 1
Answers by
Keith
Top achievements
Rank 1
Todor
Telerik team
Share this question
or