furycomputers Posted December 10, 2014 Share Posted December 10, 2014 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:Province - Ontario City - Ottawa City - TorontoProvince - Nova Scotia City - Halifax City - New GlasgowProvince - Quebec City - Montreal City - Quebec City I might get this result: Page 1Province - Ontario City - Ottawa City - TorontoProvince - Nova Scotia City - Halifax City - New GlasgowProvince - Quebec <- This hanging header is unwanted Page 2Province - Quebec City - Montreal City - Quebec CityI 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? Link to comment Share on other sites More sharing options...
Java_Jasper Posted December 18, 2014 Share Posted December 18, 2014 This may be a bit of a hack but I would recommend you use several group headers, a sub-report (for City) and an ID for each (Province). This will allow for evaluation once per cycle.Example:1) Make each province ID from the database usable in the sql queryProvince - Ontario ID = 1Province - Nova Scotia ID = 2Province - Quebec ID = 3In order to make the IDs trigger for each iteration you can use group headers, as they are evaluated once per cycle - per say.2) Now, insert some group headers more then one.3) Then place a sub report (for you it would be the City) into the footer and pass into the 'Field' which is $F{ID} This results in a sub report that triggers every time the header is evaluated, and the header will only print at the end of each sub-report. Enjoy! Link to comment Share on other sites More sharing options...
furycomputers Posted January 12, 2015 Author Share Posted January 12, 2015 I just tried your method, but it appears to result in the same problem. I'm not sure if I just need more detail from you, or I need to clarify my problem better. If you could try to explain in more detail I would be grateful. 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