iReport subreport divided by a page break

sadiqmrd picture sadiqmrd · Sep 19, 2012 · Viewed 20.5k times · Source

The subreport has two Detail bands, the first is "Title" and the second is another subreport. These bands are divided from each other on two pages.

I tried a lot of properties without result as "ignore pagination" and "split allowed"

My question is: How can I force ireport not to split my subreport on two pages ?

I have some screenshots:

The master report:

enter image description here

The subreport:

enter image description here

Another subreport:

enter image description here

The resulting pdf file looks like this:

enter image description here

Answer

GenericJon picture GenericJon · Sep 19, 2012

Instead of using two bands in the principle subreport, put the title and the second subreport into the same band. Then set the splitType for that single band to "Prevent". That way, the title and data will be kept together and the split will happen before the title if the data will not fit on the page.

Edit - Preventing the title from repeating:

Putting the title into the detail band will make it repeat with each set of data. To prevent this, change the printWhenExpression to $V{REPORT_COUNT} == 1. This will cause it to be printed only once, for the first record, and not for each subsequent loop through the datasource.