I created a few conditional styles for a text field in a table cell. The styles contains custom font formatting and background color setting. So the font formatting works great, but background color is not.
When i created the styles, i followed these steps:
- Create the style;
- In that style create two conditional styles with all settings (font and background);
- The conditions are:
- $F{DAY_OF_WEEK}.doubleValue() == 0
- $F{DAY_OF_WEEK}.doubleValue() == 1
- Apply the style to my Text Field ($F{DAY_OF_WEEK}).
Please help me figure out what is wrong here.
4 Answers:
Posted on February 15, 2017 at 12:00am
You need to remove the "backcolor" atribute on the reportElement from your JRXML.
It takes precedence over the one coming from the style.
You can manually remove the attribute:
- in the "Appearance" tab of the textField's Properties view by right-clicking the Backcolor color box and selecting the "Set to Null" option or
- from the "Source" tab of your report by directly editing the JRXML
Posted on February 14, 2017 at 4:40am
Unfortunatly, style mode="Opaque" doesn't work.
May be i did something wrong?
<style name="StyleVacation" backcolor="#A6D3A6"> <conditionalStyle> <conditionExpression><![CDATA[$F{DAY_8}.doubleValue() == 0]]></conditionExpression> <style mode="Opaque" backcolor="#F0F04D" fill="Solid" radius="4" hTextAlign="Left" vTextAlign="Top" pattern="" isBlankWhenNull="true" fontName="DejaVu Sans Mono" fontSize="1"/> </conditionalStyle> <conditionalStyle> <conditionExpression><![CDATA[$F{DAY_8}.doubleValue() == 1]]></conditionExpression> <style mode="Opaque" backcolor="#94EBB2"/> </conditionalStyle> </style> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement key="" style="StyleVacation" x="0" y="0" width="50" height="30" backcolor="#FFFFFF"/> <textElement markup="none"> <font fontName="DejaVu Sans"/> <paragraph lineSpacing="1_1_2"/> </textElement> <textFieldExpression><![CDATA[$F{DAY_8}]]></textFieldExpression> </textField> </jr:detailCell>
you can just create IF ELSE statement for your problem if my understanding is right, or left
Would you explain how can i set color in IF ELSE statement?