Jump to content
Changes to the Jaspersoft community edition download ×

Jasper reports property with condition / dynamic text forecolor


dunham

Recommended Posts

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>[/code]

 

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)[/code]

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.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...