Page number reset based on grouping.

0

Hi , im new to jasper report , i wish to know is it possible that :

Group 1 having 3 page
group 1 having 1 page

I want to display:

Group 1 : Page 1 of 3, Page 2 of 3, Page 3 of 3

Group 2 : Page 1of 1.

Possible to do this with jasper report ? 

Source:

<queryString language="SQL">
    <![CDATA[Select * from Persons where ID = $P{ID}]]>
</queryString>
<field name="ID" class="java.lang.Object"/>
<group name="myGroup" isStartNewPage="true" isResetPageNumber="true">
    <groupHeader>
        <band height="224">
            <subreport>
                <reportElement x="300" y="135" width="270" height="60" uuid="1f20858d-c055-41e2-9a60-bbc040ae6485"/>
                <subreportParameter name="ID_PERSON">
                    <subreportParameterExpression><![CDATA[$F{ID}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["subreport_1.jasper"]]></subreportExpression>
            </subreport>
            <staticText>
                <reportElement x="280" y="10" width="100" height="30" uuid="dacdfcd9-150b-419d-ba3b-b56949cd518d"/>
                <text><![CDATA[Group 1]]></text>
            </staticText>
            <break>
                <reportElement x="0" y="210" width="99" height="1" uuid="a77bf8e0-98ea-4167-b852-f2cb5f6e1cf6"/>
            </break>
            <staticText>
                <reportElement x="280" y="58" width="300" height="30" uuid="df9536c9-6584-43b3-b8b9-45fd0c0b95a6"/>
                <text><![CDATA[This report is to testing the grouping.]]></text>
            </staticText>
            <break>
                <reportElement x="0" y="111" width="100" height="1" uuid="6cda26ee-6e49-4e94-8d58-5d5dd42745e6"/>
            </break>
        </band>
    </groupHeader>
    <groupFooter>
        <band height="50"/>
    </groupFooter>
</group>
<group name="myGroup2" isStartNewPage="true" isResetPageNumber="true">
    <groupHeader>
        <band height="130">
            <subreport>
                <reportElement x="270" y="60" width="300" height="60" uuid="5663a0dc-9b14-485b-84a9-21b5e0c3b98d"/>
                <subreportParameter name="ID_PERSON">
                    <subreportParameterExpression><![CDATA[$F{ID}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["subreport_2.jasper"]]></subreportExpression>
            </subreport>
            <staticText>
                <reportElement x="280" y="20" width="100" height="30" uuid="eaa5ee0f-c0e5-4555-b321-a4db52b4efde"/>
                <text><![CDATA[Group 2]]></text>
            </staticText>
        </band>
    </groupHeader>
    <groupFooter>
        <band height="58"/>
    </groupFooter>
</group>
<pageFooter>
    <band height="57" splitType="Stretch">
        <textField evaluationTime="Group" evaluationGroup="myGroup">
            <reportElement x="400" y="10" width="100" height="30" uuid="215676d9-e972-45bd-adad-b79c1fa27112"/>
            <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="310" y="10" width="110" height="30" uuid="75a82ec2-a8ed-46dd-b5a1-147c450e32f8"/>
            <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
    </band>
</pageFooter>
crazyzai0123's picture
Joined: Sep 13 2017 - 1:50am
Last seen: 6 days 21 hours ago

3 Answers:

0

<textField evaluationTime="Group" evaluationGroup="myGroup">

I've set the evaluation Time and group but seems not working ? Did i miss something? ??

crazyzai0123's picture
Joined: Sep 13 2017 - 1:50am
Last seen: 6 days 21 hours ago
0

This is possible for the group named "myGroup", using evaluationTime="Now" for the current page number, and evaluationTime="Group" evaluationGroup="myGroup" for the total number of pages.

shertage's picture
1597
Joined: Sep 26 2006 - 8:06pm
Last seen: 6 days 11 hours ago
0

You also need to remove isResetPageNumber="true" from myGroup2. Mixing page numbering between groups mai cause unexpected results.

shertage's picture
1597
Joined: Sep 26 2006 - 8:06pm
Last seen: 6 days 11 hours ago
Feedback