Jump to content
We've recently updated our Privacy Statement, available here ×

Background color textfield depending on field value


camilo.rodriguez17

Recommended Posts

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

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)

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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/

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 4 years later...

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