Search code examples
jasper-reports

iReport: trying to hide elements B,C and D when value in A is repeated


I have a iReport question: Let's say we have 4 columns on a detail band: A,B,C and D. Column A can have the same value, and repeated values should be hidden. So I uncheck the "Print Repeated Values" property. That works.

But now I also want to hide the columns B and C when column A is empty.

Adding a "Print When Expression" on B and C like:

!($V{A}.IsEmpty())

does not work because even though the textfield of $V{A} is suppressed, the variable $V{A} still contains a value. So I cannot use that.

I would need something like: !($Textfield{A}.IsEmpty())

I also tried grouping the columns A, B and C into one element, but iReport does not have a "Print When Expression" on the group-element.

Is changing the SQL query the only option here?


Solution

  • write a query like this in ireport : select

    select count(Field A) from tablename where (your conditions) as countA, fieldA, fieldB, fieldC, FieldD from tablename where cinditions

    after this right click on fieldA write print when expressin like countA=new Integer(1)

    then this details print the fieldA value balank.

    and other field value as it is.