Background color textfield depending on field value

0

Hi there!

I have a problem with dynamic background color of textfield based on the value of field. I have the following textfields:

$F{number1}

$F{number2}

$F{number3}

.....

I have a style:

<style name="Color">
   <conditionalStyle>
     <conditionExpression><![CDATA[$F{number1} == 1]]></conditionExpression>
    <style mode="Opaque" backcolor="red"/>
    </conditionalStyle>
    <conditionalStyle>
     <conditionExpression><![CDATA[$F{number1} == 2]]></conditionExpression>
    <style mode="Opaque" backcolor="black"/>
    </conditionalStyle>
</style>

The style 'Color' works for the textfield with field $F{number1}, but, I need apply that conditionExpression to others textfields(and every one have a different field associated), but I dont want duplicate the style for every field.

Thanks for advance!!

(I'm sorry for my bad english, if it's not clear please tell me)

camilo.rodriguez17's picture
Joined: Jan 27 2014 - 10:36am
Last seen: 6 years 7 months ago

1 Answer:

1

Hi,

In order to achieve this scenario the most feasible method is what you have stated in you rquertion itself, that is creating several conditional styles, and it is not duplicating the styles, but if you are using iReport/Jaspersoft studio, then you can see that a single style can have several condional styling options so you need to apply only one style to all the textfeilds in the report and that will cater you needs according to the conditions.

 

Hope that this helps,

Thanks
Ankur Gupta
http://ankurthetechie.blogspot.in/

Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 1 month 2 weeks ago

Ankurt thanks for your answer. I understand that you say, but if I apply the unique style with multiples "conditionalStyle", and apply the same style to every field(suppose that I have 80 fields), the generation time of the report will be higher? (I think so because the evaluation of every conditionalStyle take more time, but I'm not sure I'm a newbie with jasper)

I see other software and I show that: BIRT or Reporting Services of Microsoft have the posibility to include my requeriment more faster and easy. :( .. thanks again for your help!

camilo.rodriguez17 - 6 years 11 months ago

Ankur missed the point of the question

dunham - 2 years 9 months ago

Please enlighten us with your take on the question, so that it helps the community!!

Ankur Gupta - 2 years 9 months ago
Feedback