Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New page for every group in iReport

I'm using iReport 5.6.0 and i want to create new page for each group.

For example i have table people_i_know:

Id| Name | State
1 | Tom  | friends
2 | Jim  | friends
3 | Mike | enemy
4 | Alex | friends
5 | Julie| enemy

My SQL should be like this:

SELECT Id,Name,State FROM people_i_know GROUP BY State;

And in this example iReport should give me two pages with detail band like this:

This should be on page 1.

1 | Tom  | friends
2 | Jim  | friends
4 | Alex | friends

And this should be on page 2.

3 | Mike | enemy
5 | Julie| enemy

How do i make that iReport make something like this?

like image 396
Mike Quoro Avatar asked Dec 06 '25 05:12

Mike Quoro


1 Answers

You do not need to group in query, just order them

SELECT Id,Name,State FROM people_i_know State ORDER BY State;

in jrxml

you will have a field relative to the State column

<field name="State" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>

create a group on State with attribute isStartNewPage="true"

<group name="State" isStartNewPage="true">
    <groupExpression><![CDATA[$F{State}]]></groupExpression>
</group>

and now just put the fields you like to display in the detail band

like image 92
Petter Friberg Avatar answered Dec 08 '25 19:12

Petter Friberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!