Sangeetha Kumar
Sangeetha Kumar

Reputation:

Jasper Reports - Print when group changes

I am trying to print the last record of the group but the expression print when group changes: True does not seem to work. It simply prints all the records of that group. (I've grouped the record based on username).

Upvotes: 9

Views: 23247

Answers (3)

Ilja Preuß
Ilja Preuß

Reputation: 2421

I don't think that attribute is doing what you think it does. It's supposed to be used in conjunction with isPrintRepeatedValues="false" and works the following way:

"if the repeating value you have suppressed spans multiple groups, you can make it reappear at the beginning of a certain report group if you specify the name of that particular group in the printWhenGroupChanges attribute." Ultimate Guide pg. 116

Upvotes: 7

Benjamin Johnson
Benjamin Johnson

Reputation:

I was having trouble with the same issue. Here is the work around that I came up with:

JasperReports has some automatically generated variables that may help you achieve what you want. For every group you create there is a counter that keeps track of the number of items in your current group:

yourGroupName_COUNT

In your printWhenExpression simply add an expression like the following to only print the textfield when your group ruptures:

$V{yourGroupName_COUNT}==1

-Benjamin

Upvotes: 15

Jamie Love
Jamie Love

Reputation: 5636

I've never used the 'print when group changes' functionality, but trying it now on a new report, I see what you mean - it prints for every detail record even though the group is not changing.

Instead of using the 'print when group changes' flag, uncheck the 'print repeated values' flag, this will probably give you what you want.

Upvotes: 2

Related Questions