I have a single XamReportViewer that I am using to bind to multiple different reports at runtime by using binding. These different reports have different numbers and types of data sources. I have tried to swap out the data sources in my code-behind by using the ReportProcessingRequested and ProcessingStarted however if i try to modify the ClientRenderSettings.DataSources during those calls it forces the event into a loop. Is there some other event that I should be using or is there some other method I should be using to swap out the data sources on a XamReportViewer? I can always use a template selector to pick a specific instance of a XamReportViewer template but then I would be forced to define separate templates for each report.
Hello Jerry,
I am glad to see you got this working.
Please let us know if you have any other questions.
Sincerely,ValerieDeveloper Support Engineer Infragisticswww.infragistics.com/support
I got this working -- instead of setting the ClientRenderSettings on the ReportProcessingRequested event I instead based it on an event triggered by the user changing the selection in their drop-down in the search panel. In this way the report itself and it's data sources are provided at the time the specific report to render is chosen rather than on report execution request time.
I am looking at the IReportDataSourceProvider and unfortunately because of the way that it works I don't think I could use this. The reporting engine automatically creates an instance of the matching IReportDataSourceProvider class object and then calls GetDataSource on it, however I would need the class that I write that implemented IReportDataSourceProvider to have a link to the ViewModel that actually contains all of the data that the user has chosen to add to the report. If I can't control the creation of the IReportDataSourceProvider that the engine uses then I can't ensure that the provider has a link to the information that the user has chosen to add to each section of the report.
Sure -- I have two ContentPanes in a TabGroupPane of a XamDockManager that are involved with the report generation. The first is a search and report selection pane and the second is the report pane.
In the search pane the user will run a search against a backend service which provides data from a backend database. In the search pane also the user has a drop-down from which they can choose which report they want to run. The drop-down is populated from a list of reports which I have stored in the backend database as well and correspond to .igr files. Once a user chooses a report from the drop down, in the bottom of the pane is a XamTabControl, each tab of which represents a single section in the chosen .igr report. The user can then drag and drop whichever items from the search results into whichever section of the report they like. They can run multiple searches and drag items from those results into the report selection tab control.
Once the user is done dragging items into the report selection tab control, or if they want to see what the report looks like as they are adding items, they can look at the report pane which contains a XamReportViewer. So basically I need to be able to swap out the DataSources of the ClientRenderSettings of the XamReportViewer in the report pane at the time that the user chooses which report they want from a drop-down in the other search and report selection pane. I could probably do this through the MVVM Light messenger to communicate between views. I started out trying to do this by using some event on the XamReportViwer as a matter of convenience.
Alternatively I may be able to use the IReportDataSourceProvider but I'd need to look into exactly where to hook that into my infrastructure.
Changing the datasource on the ReportProcessingRequested event is not feasible and it is part of the reason why IReportDataSourceProvider exists - to provide a way to change the data source of a report when it is being rendered. Regarding the flexibility you need, can you explain what you are trying to accomplish?