Background color in conditional style doesn't drawn

0

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: 1 year 10 months ago

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

taepoop12 - 2 years 5 months ago

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

shuhovivan - 2 years 5 months ago

4 Answers:

0

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
1027
Joined: Nov 22 2010 - 12:39am
Last seen: 3 hours 2 min ago
2

You have to check 

style mode="Opaque" in conditionalStyle with backcolor

HTH

sanbez's picture
834
Joined: Jan 11 2011 - 2:06am
Last seen: 1 month 4 days ago
0

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>

shuhovivan's picture
Joined: Feb 10 2017 - 1:56am
Last seen: 1 year 10 months ago
0

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

avinash.eng18's picture
Joined: Jan 18 2016 - 10:24pm
Last seen: 10 months 4 weeks ago
Feedback