Jump to content

Background color in conditional style doesn't drawn

Go to solution Solved by narcism,

Recommended Posts

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.

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

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


Link to comment
Share on other sites

  • Solution

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
Link to comment
Share on other sites

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...