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

Conditionally control Print Group Header on new Page


ian.waterman

Recommended Posts

Building a report which lists out invoices within an agreement. The headers for the invoice details are in the Agreement Header.

Generally works fine however, if list of invoices goes over to next page I want the Agreement header to repeat. I have tried checking the Reprint Header on new page , but that causes header to reprint irrespective whether invoice list flows onto next page.

I created a Count of Agreements which Increments and resets on the Agreement Group and a record count. According to this entry https://community.jaspersoft.com/wiki/variables the agrement count should only evaluate on change of Agreement. However, it seems to count every record.

I had hoped that I could use a print when expression that only allows the Agreement Header to print when the two counts are equal and <> 1, (in most cases invoice list is more than 1 but had this just incase)

However, as the two counts are always equal the header always prints. 

What am I doing wrong with the Count Variables 

Is there a better way to conditionally control the subsequent printing of the agreement header

Source Description of Vars

</variable>
    <variable name="PHControl" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber" incrementType="Group" incrementGroup="AgreementNumber">
        <variableExpression><![CDATA[$V{PHControl}+1]]></variableExpression>
        <initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
    </variable>
    <variable name="RecNo" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber">
        <variableExpression><![CDATA[$V{RecNo}+1]]></variableExpression>
        <initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
    </variable>

Thank you

Ian

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You need an increment type defined for RecNo, which would be "Page". Also, I don't think you need PHControl.

On the first page, RecNo is set to zero. On the second page it is set to 1, and on the third it is 2...etc. When group resets, it becomes zero again (first page for new group).

However, if you are tying to do something else, please clarify your question.

Link to comment
Share on other sites

Kevin

Thank you for guidance,

Still not working as expected

I have changed Vars as suggested

</variable>

<variable name="RecNo" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber" incrementType="Page">

<variableExpression><![CDATA[$V{RecNo}+1]]></variableExpression>

<initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>

</variable>

<variable name="PHControl" class="java.lang.Integer" resetType="Group" resetGroup="AgreementNumber">

<variableExpression><![CDATA[$V{RecNo}]]></variableExpression>

<initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>

</variable>

Print when on Header is set as

</group>

<group name="AgreementNumber" isReprintHeaderOnEachPage="true" keepTogether="true">

<groupExpression><![CDATA[$F{AgreementNumber}]]></groupExpression>

<groupHeader>

<band height="149">

<printWhenExpression><![CDATA[$V{RecNo}.doubleValue()!=$V{PHControl}.doubleValue()]]></printWhenExpression>

<textField isStretchWithOverflow="true" evaluationTime="Group" evaluationGroup="AgreementNumber" pattern="" isBlankWhenNull="false">

I have placed VARs on report on Page in both Group Header and Footer. In Header PHControl = 2 and Recno = 1

In Footer They are both 2 on pg1 however, group header still prints on Page 2

Cant see how Values are being set?

Any suggestions?

Ian

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