How can I use a conditional TextField in JasperReports?

前端 未结 3 673
闹比i
闹比i 2021-01-02 05:54

I would like to have a pair of TextFields depending on a value. And the \"y\"-value should be adjusted depending on the empty space.

When the value is \"0\"

相关标签:
3条回答
  • 2021-01-02 06:10
    <reportElement ...>
        <printWhenExpression><![CDATA[$P{red} == 0]]></printWhenExpression>
    </reportElement>
    

    You can use iReport to modify this with a pleasant UI.

    0 讨论(0)
  • 2021-01-02 06:15

    In this way, no, I'm not sure it's possible.

    There is an option called Remove Link When Blank, but it only works if you want to remove the whole line. Here you want to remove one line in specific column.

    In this case I would recommend using crosstab or CrossTables feature.

    Give the Column Group the value of X. (supposing X is the column number) And give the Row Group the value of the color field, from here you can change the label dynamically, something like this:

    $F{color}==null?"": ($F{color}.equals("RED")?"Red Items":"Blue Items")
    
    0 讨论(0)
  • 2021-01-02 06:19

    you can use like this

    Declare RED as [class="java.lang.Number"]
    

    while printing

    $P{red}.intValue() == 0 ? null : $P{red}.intValue()
    

    and enable Blank when null option of the field using

    textField isBlankWhenNull="true">               
    <reportElement x="100" y="30" width="100" height="30" isRemoveLineWhenBlank="true"/>
    
    0 讨论(0)
提交回复
热议问题