Jump to content
Changes to the Jaspersoft community edition download ×

Counting pages from subreport to main report


grototo

Recommended Posts

Hi Folks,

gotta weird need, and I can't seem to find a solution.

Main report :

  • calling subreport 1 in detail1 section
  • calling subreport 2 in detail2 section
  • using pagefooter to print "page 1.x", where x shall be the page number from the subreport.

For instance, if subreport 1 prints 3 pages at first time, page number should be 1.1, 1.2 and 1.3.

And so on....Starting again from 1.1, 1.2, aso for each brand new objet of the list given to each subreports.

I tried using different evalution times, but I can't get it working.

Never used returned parameters, 'cause I can't get how it works.

Any help would be appreciated ;)

Best regards,

Thomas

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

For usage of ReturnVariables that's not so difficult. You will need to define a Variable let's call "SR_TotalPageNumber" in your MainReport.

At your SubReport-Element you create the mapping within the ReturnVariables, where you define which source-variable from SubReport will be transferred to what target-variable in MainReport... so $V{PAGE_NUMBER} (that is incremented individually from (each) SubReport) must be mapped to $V{SR_TotalPageNumber}  (in MainReport)

In your MainReport you can now use as PageXbyY Expression SV{PAGE_NUMBER} + "." + $V{SR_TotalPageNumber} and set the Evaluation-Time to PAGE for that textfield. 

But in your case you will recognize that the ReturnVariables are evaluated when the SubReport returns... so this will just happen at the SubReport-End, so when it's finished rendering it's own pages. 

So probably the trick with ReturnVariables won't work. So I would recommed to use some groups instead, there you could adjust that the PageNumbers will be resetted when the Group breaks! So I guess this will fit more your needs.

Just give it a try! Otherwise you could also render the page-footer within the SubReports itself.... there you have it's own total-page-numbers of course. But then you should also redesign your MainReport and let the SubReports RunToBottom probably (so not sure if this is feasible in your case)

What also could work... create a group for the SubReport(s) and place the SubReport(s) into the groupfooter(s) instead of the detail(s). Now you could also try to set the Evaluation-Time of your PageXbyY-Element to "Group" and select the named group. (also just an idea, not tried/proofed)

hth + regards

C-Box

Link to comment
Share on other sites

fine that it works.  So it wasn't "another" solution ... but the second Idea I've mentioned:

. Otherwise you could also render the page-footer within the SubReports itself.... there you have it's own total-page-numbers of course. But then you should also redesign your MainReport and let the SubReports RunToBottom probably (so not sure if this is feasible in your case)

 ;-)

regards

C-Box

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...