New page for each sub report

Hi there,

 

I am working on a report that contains 8 subreports inside a detail band. All of these subreports have the potential to either not exist (with the exeption of the first subreport always existing), or have 1 to n rows, making the page height an unknown value. I would like it so each subreport starts on a new page. My current solution is this:

Master report

-- SubReport1

-- SubReport2 - With pagebreak at top of title band

-- SubReport3 - With pagebreak at top of title band

-- SubReport4 - With pagebreak at top of title band

-- SubReport5 - With pagebreak at top of title band

-- SubReport6 - With pagebreak at top of title band

-- SubReport7 - With pagebreak at top of title band

-- SubReport8 - With pagebreak at top of title band

This current solution works fine when the contents of previous subreport doesn't take up all of the page height. In cases where the previous subreport does this - the page break from the current subreport no longer fits on the previous subreport's page and instead inserts a page break on the following page. This means there is the occasional blank page in the middle of the report.

My question is - is there a better solution to generating each subreport on a new page, if not, is there a way I can modify the current structure so that I can achieve my desired look?

Regards,

Steve

stephen whitehead's picture
Joined: Jul 6 2017 - 8:25am
Last seen: 3 years 7 months ago

5 Answers:

Here is a suggestion on how I often setup numerous "sub-reports".

Each band can have its own properties.

One of those properties is Start New Page.

I would have each dataset (subreport) in a new detail band.  (right click and add detail band)

You can set the condition on whether they display or not to be if the dataset contains data if you are getting any blanks you don't want.

danoldenkamp@gmail.com's picture
Joined: Aug 29 2018 - 11:12am
Last seen: 2 years 2 months ago

Hi Dan,

I need all of my subreports to start at the exact same height on each page. Is this possible with detail bands as I believe they follow on from the previous Y coordinates, meaning each subsequent subreport will fall below the one above it on the page.

Regards,

Steve

stephen whitehead's picture
Joined: Jul 6 2017 - 8:25am
Last seen: 3 years 7 months ago

Have you tried it yet?

I have never had that problem.   When I have dozen of bands down the page only 1 ever true (radio parameter) they are all at the top of the page. (or relative to the headers)

If the band properties "Print when expression" does not result true I don't believe that band renders at all.

 

 

danoldenkamp@gmail.com's picture
Joined: Aug 29 2018 - 11:12am
Last seen: 2 years 2 months ago

Hi Dan

I have been having issues trying to apply the Start New Page property in the jrxml. Would you be able to provide me a snippet of one of your reports that implements this feature so that I can try it myself?

Cheers for the continued help,

Steve

stephen whitehead's picture
Joined: Jul 6 2017 - 8:25am
Last seen: 3 years 7 months ago

I made an example one for you. 

Works fine for me without setting the Start New page property.

My trick is on all reports I create a variable called nothing with an expression of ""  (blank).

Create a new group from the nothing variable.

and sett the reports when no data type to: All sections No detail.

 

I also always set the language from java to groovy because of issues i have seen in the past.

See attachment.

When I toggle from list1 to list2, only the list is visible and at  the top of page.

See the print when expression for the two bands:

$P{SubReportSelector}=="list1" and

$P{SubReportSelector}=="list2"

 

 

 

Attachments: 
AttachmentSize
Binary Data subreportselector.jrxml2.58 KB
danoldenkamp@gmail.com's picture
Joined: Aug 29 2018 - 11:12am
Last seen: 2 years 2 months ago
Feedback