Hide text box if sub file is empty

I create a report in Jasperfour parts. Each part consists of a text field as a title and subtitle. The sub-register may be empty. If it is empty, it is hidden using "Delete line with empty". It still works. Now the corresponding header text box should also be hidden if the hidden sub-screen is hidden.

I tried many things but could not find a solution. For example. for When the Expression using the Print: new Boolean ($P{otherField}.read() != -1). It never showed a headline.

I also tried to hide the title in my Java program, but could not find the corresponding API command. I think it getBands()[x].getChildren()[y]will lead me to the correct title, but I could not hide it there.

Any other ideas?

+4
source share
2 answers

Thank you for your help. I finally was able to solve it using the following expression in the "Print with Expression" section in the header:

($P{SUBR}!=null)

Where

$ P {SUBR}

- expression of the subreport.

-1
source

You should put the caption text inside in a subreport, for example, in a titlerange

Subtitled

<title>
    <band height="38">
        <textField>
            <reportElement x="10" y="0" width="100" height="20" uuid="4b8ece47-1608-4d08-bc0b-e6b73bcf8346"/>
            <textFieldExpression><![CDATA["TITLE"]]></textFieldExpression>
        </textField>
    </band>
</title>

Make sure you don't have the whenNoDataType attribute in the tag jasperReport, so it uses the default valueNoPages

If there are no entries in the subreport, the attribute whenNoDataType=NoPages(by default) ensures that nothing is returned and you do not see the header.

( - ), printWhenExpression evalutationTime="Report"

, .

report_count iReport

+6

Source: https://habr.com/ru/post/1623460/


All Articles