Background color in conditional style doesn't drawn

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:
  1. $F{DAY_OF_WEEK}.doubleValue() == 0
  2. $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.

shuhovivan's picture
Joined: Feb 10 2017 - 1:56am
Last seen: 4 years 11 months ago

you can just create IF ELSE statement for your problem if my understanding is right, or left

taepoop12 - 5 years 6 months ago

Would you explain how can i set color in IF ELSE statement?

shuhovivan - 5 years 6 months ago

4 Answers:

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
narcism's picture
Joined: Nov 22 2010 - 12:39am
Last seen: 6 hours 48 min ago

You have to check 

style mode="Opaque" in conditionalStyle with backcolor


sanbez's picture
Joined: Jan 11 2011 - 2:06am
Last seen: 1 year 10 months ago

Unfortunatly, style mode="Opaque" doesn't work.

May be i did something wrong?

<style name="StyleVacation" backcolor="#A6D3A6">
        <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"/>
        <conditionExpression><![CDATA[$F{DAY_8}.doubleValue() == 1]]></conditionExpression>
        <style mode="Opaque" backcolor="#94EBB2"/>
<jr:detailCell style="Table_TD" height="30">
    <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"/>

shuhovivan's picture
Joined: Feb 10 2017 - 1:56am
Last seen: 4 years 11 months ago

you can change the code, with  style mode="Opaque" 

avinash.eng18's picture
Joined: Jan 18 2016 - 10:24pm
Last seen: 1 week 6 hours ago