Jump to content
We've recently updated our Privacy Statement, available here ×

Sub-reports using different JRDataSources


citress

Recommended Posts

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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...