I have a problem with conditionalStyle in iReport. I have the following textFields (${nameField} = field value):
${field1}=30 ${field2}=40 ${field3}=50
${field4}=23 ${field5}=1 ${field6}=45
${field7}=34 ${field8}=20 ${field9}=0
I need set difference background in every textField depend of the value of the field. I create a new Style and set the conditions:
<style name="ColoredField">
<conditionalStyle>
<conditionExpression><![CDATA[$F{field1} == 300]]></conditionExpression>
<style mode="Opaque" backcolor="#FCFF00"/>
</conditionalStyle>
</style>
As you can see, the Style use only $F{field1}
, and I need make a dynamic style (or something), that apply to every textField.
Try ths one :
Your question is not clear, can you be more explicit ?
From my understanding , each value will mean a specific background for a textfield, in that case your conditional style value should depend on variable. Maybe using Variables in your style can suit your need.
Add multiple conditional style under each style as below:
each textField can now have different background :
I could not find a direct way to accomplish this task - you have to create a separate style for each field.
Considering this you can concentrate your effort on creating a small script that replicate the XML with the same stile for the fields you have. Then you can just copy/paste the XML into the report source file. Each time you need to change the style you will have to go back to your XML generator.