I am using iReport's to format the results of a query. The results are currently something like this:
Id firstname surname - id firstname surname
1 dan n 45 dan n
1 dan n 46 dan n
3 john d 102 john d
4 john f 109 john f
4 john f 110 john f
I would like them to look more like this:
Id firstname surname - id firstname surname
1 dan n 45 dan n
46 dan n
3 john d 102 john d
4 john f 109 john f
110 john f
I know that iReport has the 'print when Repeated Values feature, but if i use this I get the following happening:
Id firstname surname - id firstname surname
1 dan n 45 dan n
46 dan n
3 john d 102 john d
4 f 109 john f
110 john f
Because iReports recognises the second John as a repeat and so removes it.
So my question is, is there a way to do this? I have not been able to find a way to group the elements and then not repeat on the id field. I tried playing around with keeping track of the last 2 id's and then printing on whether the current matches the last, but haven't been able to figure out how to get it to update each time so that it keeps track.
Does anyone have any ideas?
I am using ireport (and jasperreports) 3.6.1 and know to make a query that will return what i need but would rather that the formatting is done on the report side.
Best Answer
Create a group on
$F{Id}
called MyGroup. Don't create a group header or group footer. [At this point your report will still look exactly as it does in your first version.]Then add a Print When Expression to each of these fields: Id, firstname, surname. The Expression should look like this:
That let's you print your fields once per ID.