Reputation: 11
Currently I'm doing report using iReport 3.0.0
I have this one field which is Indicator
(A, B and C).
I group by this field so that All records will print in different page based on Indicator
. (I use iReport Group By
function)
However, I have certain time that when it query my sql, it will return only A and C.. How if I wanna generate Ind = B
too with text NO RECORD FOUND
This is my current expression:
($F{IND}.equals("A")) ? "SMS MESSAGE NOT FOUND" : (
($F{IND}.equals("B")) ? "CW MESSAGE NOT FOUND" : (
($F{IND}.equals("C")) ? "STATUS MIS-MATCHED" : null
)
)
How can I check if IND = B
not exist in my database, then print NO RECORD FOUND ?
Thanks in advance for your help !
Upvotes: 0
Views: 107
Reputation: 1827
You can use a special variable to count the rows in the group B.
Either use the built-in variable ${YOUGROUP_COUNT}
(source)
Or increment a variable yourself : see more information here
When you have this variable set up, you can have a textField
containing NO RECORD FOUND. Use the attribute printWhenExpression
to display this textField only when the group count is equal to zero.
<staticText>
<reportElement x="234" y="10" width="100" height="30" uuid="05895bf2-3ce1-4d88-82fe-ff3fd650eaf6">
<printWhenExpression><![CDATA[${YOURGROUP_COUNT} == 0]]></printWhenExpression>
</reportElement>
<text><![CDATA[NO RECORD FOUND]]></text>
</staticText>
Don't display this static text element in a detail band, because it won't be displayed if there is no record. Use any other band to display it.
Upvotes: 1