Hendri Potgieter
Hendri Potgieter

Reputation: 105

Jasper report blank bands still takes up space

My problem is that even though the line is blank it still takes up the space of the height of the band and thus there is a larger gap than usual before the next band.

The band in my jasper file looks like this:

<band height="30" splitType="Stretch">
    <staticText>
        <reportElement uuid="274e9a4d-939e-46f6-8508-52ebc9051180" x="0" y="10" width="515" height="20" isRemoveLineWhenBlank="true" forecolor="#111B3F">
            <printWhenExpression><![CDATA[$F{projects_count} != "0"]]></printWhenExpression>
        </reportElement>
        <textElement verticalAlignment="Top">
            <font fontName="Arial Black" size="14" pdfFontName="jasper/fonts/ARIBLK.TTF"/>
        </textElement>
        <text><![CDATA[Project experience]]></text>
    </staticText>
</band>

Here I have text staticText that should only display when <![CDATA[$F{projects_count} != "0"]]>. This works. On the reportElement I also set isRemoveLineWhenBlank="true"

Since the height is set to 30 it still takes up space in my report and I can't seem to figure out how to not only not display the text but also remove the band in a way if it does not meet some condition.

Upvotes: 4

Views: 8260

Answers (2)

Lisa
Lisa

Reputation: 1341

Hendri -- am I understanding that you have set the Print When expression on the text field within the band? Set the Print When expression for the whole detail band instead.

 <band height="30">
     <printWhenExpression><![CDATA[$F{projects_count} != "0"]]></printWhenExpression>
            <textField> {... etc}

Upvotes: 7

Hendri Potgieter
Hendri Potgieter

Reputation: 105

I found a solution right after posting.

It actually works but because I have a height of 30, and my staticText only has a height of 20 starting at y=10, there are 10 pixels(y=0-9) that won't be removed. I fixed this by changing height to 20 and y to 0 like this:

<band height="20" splitType="Stretch">
    <staticText>
        <reportElement uuid="274e9a4d-939e-46f6-8508-52ebc9051180" x="0" y="0" width="515" height="20" isRemoveLineWhenBlank="true" forecolor="#111B3F">
            <printWhenExpression><![CDATA[$F{projects_count} != "0"]]></printWhenExpression>
        </reportElement>
        <textElement verticalAlignment="Top">
            <font fontName="Arial Black" size="14" pdfFontName="jasper/fonts/ARIBLK.TTF"/>
        </textElement>
        <text><![CDATA[Project experience]]></text>
    </staticText>
</band>

Upvotes: 0

Related Questions