0
votes

Depending on Parameters some text fields are not displayed in Title Band header in my report.

But Title band height is fixed. So either I have empty blank space in title band when text fields are not displayed. Or there is compilation error when I make band height smaller and those fields are displayed.

So how to make dynamic Title Band height?

<parameter name="param" class="java.lang.Boolean">
    <defaultValueExpression><![CDATA[true]]></defaultValueExpression>
</parameter>
<title>
    <band height="128" splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
        <staticText>
            <reportElement x="30" y="90" width="100" height="30" uuid="4e7618ed-21d8-47d2-99fb-7b88a5b7cfce">
                <printWhenExpression><![CDATA[$P{param}]]></printWhenExpression>
            </reportElement>
            <text><![CDATA[Static Text]]></text>
        </staticText>
        <textField>
            <reportElement x="30" y="10" width="100" height="30" uuid="005a53c9-a02d-436f-b35d-526ccf4aace9"/>
            <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="30" y="50" width="100" height="30" uuid="caa2031a-3b71-43a2-bb39-916599872e94"/>
            <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
        </textField>
    </band>
</title>
<pageHeader>
    <band height="43" splitType="Stretch">
        <textField>
            <reportElement x="30" y="6" width="100" height="30" uuid="30652d38-43f3-4574-a743-bb6240c2cb52"/>
            <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
        </textField>
    </band>
</pageHeader>

In this example there is blank space when param == false. But if I make title band height smaller there is compilation error.

1
You should post small jrxml to reproduce the issueAlex K
I've posted example.kostepanych

1 Answers

1
votes

You have to set isRemoveLineWhenBlank to true for the text field.

<reportElement x="30" y="90" width="100" height="30" isRemoveLineWhenBlank="true" uuid="4e7618ed-21d8-47d2-99fb-7b88a5b7cfce">