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

How to change Field Color dynamically?


rasikow

Recommended Posts

 Hi all,

 

i want to change color of field dynamically? is it possible through jrxml?

For example,

if field is G, it should be Green color, if R, it should be Red color

 

your swift reply shall be highly appreciated. Thanks in  Advance

 

- Gnaniyr Zubair

 

 

Link to comment
Share on other sites

  • Replies 13
  • Created
  • Last Reply

Top Posters In This Topic

rasikow
Wrote:

Thanks. i have got solution from one forum. her is code: ($F{currentStatus}.equals("Submitted"}) ? " " : $F{currentStatus} )

 

if i use like this,

 

($F{currentStatus}.equals("Submitted"}) ? "<style forecolor='red'>"+ $F{currentStatus}+"</style>: " : $F{currentStatus} )

 

i got the output:  <style forecolor='red'> instead of changing text color.

 

Link to comment
Share on other sites

phantastes
Wrote:

rasikow,

You could set up different Styles

or

you could use two different fields with different font colors. Then put the a filter in the "Print When Expression" :

new Boolean($F{currentStatus}.equalsIgnoreCase("Submitted") == true)

Magnus

 

Hi Magnus,

 

Thanks for your reply. yaeh i got the point.

But i dont know how to use Print When Expression as i dont get proper documentation. can u pls guide on this?

Also i used the HTML Markup for that particular field. but it is not working. 

Thanks in advance

 

- Gnaniyar Zubair

Link to comment
Share on other sites

Hi Guys, I am also looking for this solution. I don't see anything when I click the drop down "Style". I am using version 1.2.x of iReport.

I am also trying two text boxes with two different colors logic but not sure why my expression is not evaluating correctly.  I have two dates, I want to show textbox1 with blue color only when the start_date<>EndDate. If both dates are equal, then I want to show textbox2 with black color. The problem is my expression is returning only one textbox1 in all cases. I wish I could change the font color dynamically with some other logic.

 

Here is what I have.

//TextBox1 - text color is Blue

$F{Start_Date}==$F{End_Date}?Boolean.FALSE:Boolean.TRUE 

//TextBox2 - text color is Black

$F{Start_Date}!=$F{End_Date}?Boolean.FALSE:Boolean.TRUE

 

Link to comment
Share on other sites

Both are defined as date. But I was able to figure out after little searching. The following expressions are working fine:

Box1:(blue color)

//for equal to

$F{START_DATE}.equals($F{END_DATE})?Boolean.FALSE:Boolean.TRUE

 

Box2: (black color)

//for not equal to

!($F{START_DATE}.equals($F{END_DATE}))?Boolean.FALSE:Boolean.TRUE

 

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 years later...

hello all,

i don't oppened new topic bcz i have similar problem but i want to make border

i did this $F{NAME}=="Submitted1"?$F{NAME}:"<style backcolor='red'>"+$F{NAME}+"</style>"

but if i want border around text style isn't recognize border in this style

anyone can help me?

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