citress Posted September 9, 2010 Share Posted September 9, 2010 Hi, I would like to include multiple sub-reports in a master report, using different JRDataSources for each sub-report. Is this possible? I know that another approach is to create individual reports and then concatenate them into a single report using JRExporterParameter.JASPER_PRINT_LIST to specify multiple reports, but doing it this way, I have no control over page breaks, as each report is on it's own page. With sub-reports, I can position two sub-reports in the same page of the master report.Any ideas? Link to comment Share on other sites More sharing options...
szaharia Posted September 10, 2010 Share Posted September 10, 2010 In order to work with multiple datasources, you could access them using <dataSourceExpression/> or <connectionExpression/> for each subreport element in your report.Hope this helps,sanda Link to comment Share on other sites More sharing options...
citress Posted September 10, 2010 Author Share Posted September 10, 2010 I did try using dataSourceExpression, but since I using JRBeanCollectionDataSource, there can only be one bean type in the collection. For each of my subreports, they require different bean types and each bean collection has to be sorted differently (for proper grouping in iReport). So it seems to me that I cannot use dataSourceExpression. If I am missing something, please let me know. I am not connecting to the database directly from within iReport, so that would preclude me from using connectionExpression. Link to comment Share on other sites More sharing options...
jgaughan Posted September 10, 2010 Share Posted September 10, 2010 If you can precalculate the beans ahead of time, just put them in the report as a parameter, and pass that into the subreport's data source: <dataSourceExpression>$P{SubreportParameter}</dataSourceExpression> If the subreport's data source relies on properties of the parent reports current record, you can try calling out to a helper: <dataSourceExpression>$P{HELPER}.getSubreportDataSource($F{FieldName})</dataSourceExpression> Link to comment Share on other sites More sharing options...
citress Posted September 10, 2010 Author Share Posted September 10, 2010 Thanks! This looks promising. I will give that a shot. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now