Search code examples
jasper-reports

How to repeat a single band in group header if the detail section spans for multiple pages?


I need to repeat the immediate band if the detail section spans for multiple pages.

Below is my source code related to group headers. Here I want to repeat the 2nd band (height = 25) if the detail band spanned to the next page. How can I repeat only the 2nd band

<group name="Lines">
    <groupExpression><![CDATA[$F{ordernum}]]></groupExpression>
    <groupHeader>
        <band height="102">

        </band>
        <band height="25">

        </band>
    </groupHeader></group><detail>
    <band height="40" splitType="Stretch"></band></detail>

enter image description here


Solution

  • Instead of 1 group with 2 bands use 2 groups with 1 band and set the attribute isReprintHeaderOnEachPage to true on the group you like to reprint on every page.

    <group name="Lines1">
        <groupExpression><![CDATA[$F{ordernum}]]></groupExpression>
        <groupHeader>
            <band height="102">
            ...
    </group>
    <group name="Lines2" isReprintHeaderOnEachPage="true">
        <groupExpression><![CDATA[$F{ordernum}]]></groupExpression>
        <groupHeader>
            <band height="25">
            ....
    </group>