Search code examples
jasper-reports

Field does not stretch as expected with overflow in group header in iReport


I have a text field in ireport that can be upto 500 characters long i have placed it in group header and is set to stretch with overflow.But when it stretches,it overlaps with the fields below.How can i make it to not overlap with other fields.

enter image description here

and this is the design::

enter image description here


Solution

  • From jasper point of view the problem is not that its not stretching the problem is that the fields below are not allowed to move.

    So lets tell them to move, set positionType on JRElement to Float

    <textField>
        <reportElement positionType="Float" x="0" y="0" width="100" height="20" uuid="e439886e-6e58-450d-b87f-70ba76233fbc"/>
        <textElement verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$F{YourFieldsThatNeedToMove}]]></textFieldExpression>
    </textField>
    

    The different positionType are:

    FixRelativeToTop - (default) The current report element simply ignores what happens to the other section elements and tries to conserve the y offset measured from the top of its parent report section

    Float - The element floats in its parent section if it is pushed downward by other elements found above it. It tries to conserve the distance between it and the neighboring elements placed immediately above it

    FixRelativeToBottom - If the height of the parent report section is affected by elements that stretch, the current element tries to conserve the original distance between its bottom margin and the bottom of the band