Jasper reports property with condition / dynamic text forecolor

0

I have a simple text field in a subreport.

Goal: Apply "propertyExpression" for "Forecolor" only when the parameter "evenRow" is 1

Following does not work but I gave it a try...

 

<textField>
  <reportElement key="" mode="Transparent" x="108" y="1" width="76" height="13">
    <propertyExpression name="net.sf.jasperreports.style.forecolor">
        <![CDATA[$P{evenRow}.equals("1") ? $P{colorZebra1_text} : ""]]>
    </propertyExpression>
  </reportElement>
  <textElement><font fontName="SansSerif" size="8"/></textElement>
  <textFieldExpression>"Text"</textFieldExpression>
</textField>

Context: The parent report calls this! subreport which contains the textfield multiple times (illustrated in attached image). Each time it is called the parent report sends the parameter "evenRow" as either 1 or 0...

//snipped from parent report to show that "evenROW" is 1 or 0
($V{REPORT_COUNT}.intValue() % 2 == 0 ?   1 :    0)

Question: How can I create a propertyExpression for the dynamic "Forecolor" that only comes to effect when my parameter "evenRow" is set to 1 ?

enter image description here

Note: I am aware I could use conditional styles -> The problem with styles in general is that they are never dynamic, i.e. I would have to create 1 style for every single color that 'could' be set ...and because the color can be set to whatever hex value this is not an option.

dunham's picture
36
Joined: Oct 18 2013 - 6:57am
Last seen: 1 month 1 week ago

0 Answers:

No answers yet
Feedback