Jump to content
We've recently updated our Privacy Statement, available here ×

Subreport totals in group footers problem


Recommended Posts

I've been working on dynamic report generation add-on to our application that creates a report on demand by the user. This is done completely in Java, no pre created jrxml files are used. We have classes that represent the base of each report and custom datasources that take advantage of pre-built calculations for the database. There is also a UI that allows the user to set conditions and insert groups dynamically. The groups allow for a total which is where my problem comes in.

If I run a report where there is no subreport, everything works as expected. However, when I use a report that uses a subreport in the detail band, I find that the group footer totals get generated before the subreport has a chance to run, meaning that the totals are not available. I have played around with the setEvaluationTime() variables but with no luck. When I debug the custom datasources, I see the JRFields representing the group footer totals being requested in the main report datasource before the JRFields in the subreport datasource.

The question I have is how do I ensure that the subreport in the detail generates its values prior to the group footer using the Jasper Reports API? I have not been able to find any java code samples to do this. As well, the java doc for the JasperReports API is details on some of the methods/variables available so I have not been able to find an answer there.


Any insight/help would be greatly appreciated. Thanks in advance.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi Teodor,


What I am trying to do is have the totals of the subreport available in the footer of the main report so that the values can be summed up. The scenario is we have basic reports that the user can work with. From a UI, the user can select other conditions to break down the report. These become group headers in the main report and the totals of the subreport are placed in the group footer.


I did find out since this post that the problem stems from the way I use fields in the report.Basically, the field representing the subreport total in the footer is filled before the subreport is filled.


I did work out a solution yesterday. What I am doing now is that when the main reports custom datasource next() method is called, I run the subreports custom datasource and cache the values. I am then able to use a variable of the totals when needed.


Most of this is self taught, so I am not sure if this is the best way to do things. Except for this one issue that is now resolved, I have been able to accomplish what I set out to do.


Thanks for your reply.


Steve [file name=jrReport1156281234857.jrxml size=39294]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/jrReport1156281234857.jrxml[/file]

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