I am creating a jasper report with some very specific requirements.
- The report contains a group.
- The group header must print at the beginning of the group and also on a new page.
This is not a problem since I just have to tell it to "Reprint Header On Each Page". So far so good.
- The detail section is not allowed to split across a page.
- The group header must not print at the bottom of a page unless at least one detail section will fit. (Could be rephrased as: The group header must only print when at least one detail section will fit)
At this point I noticed that there is a property for the group called "Min Height To Start New Page". This would be useful for a detail section of constant height, however...
- The detail section is dynamic height.
I have tried using "Keep together" on the group, but that can leave too much blank space on pages if the first group is small, but the second is large. It was rejected as a solution.
With these requirements in mind. All I am trying to do is not print the group header when the page cannot fit any detail entries.
I suspect that when it is filling in the report that it probably doesn't know the height of the detail section until it has filled it in, and by then it is too late. I'm hoping I am wrong.
I have tried recreating this report in two ways:
- One report with a group and detail sections.
- A main report with a subreport for the group, and within the subreport another subreport for the detail.
Both ways have led me to the same results.
Visually, if this was my data:
I have tried many permutations of settings, placing the subreports in different bands, but I haven't found something that works. I am hoping someone knows of a combination of settings, placing subreports in different bands, etc. that will work.
Any idea how I might accomplish this?