How to change Field Color dynamically?

0

 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

 

 

rasikow's picture
12
Joined: Nov 10 2008 - 3:35am
Last seen: 10 years 4 months ago

13 Answers:

0
Thanks. i have got solution from one forum. her is code: ($F{currentStatus}.equals("Submitted"}) ? " " : $F{currentStatus} )
rasikow's picture
12
Joined: Nov 10 2008 - 3:35am
Last seen: 10 years 4 months ago
0

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.

 

rasikow's picture
12
Joined: Nov 10 2008 - 3:35am
Last seen: 10 years 4 months ago
0

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

phantastes's picture
Joined: Aug 22 2008 - 2:05pm
Last seen: 5 years 10 months ago
0
Did you remember to set Markup to styled?
drlaz's picture
28
Joined: Aug 31 2007 - 5:13am
Last seen: 11 years 6 months ago
0

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

rasikow's picture
12
Joined: Nov 10 2008 - 3:35am
Last seen: 10 years 4 months ago
0

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

 

dprogrammer's picture
Joined: Jul 19 2006 - 7:37am
Last seen: 10 months 3 weeks ago
0

Start_Date and End_Date are defiend as what data type?

svenn's picture
1345
Joined: Mar 19 2007 - 5:57am
Last seen: 12 years 6 days ago
0
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
dprogrammer's picture
Joined: Jul 19 2006 - 7:37am
Last seen: 10 months 3 weeks ago
0
Dear Gnaniyr Zubair I found out a way to do this: in the TEXT FIELD: ($F{sysdate-4}.compareTo(new BigDecimal(0))
mauropiro's picture
Joined: Feb 12 2009 - 4:50am
Last seen: 1 year 1 month ago
0

 Hi  Mauro,

Could you please explain what you did in your case?

If you share some snap of code here that could be easy to understand too.

Thanks,

Ajay

ajaynayak's picture
Joined: Apr 20 2012 - 2:27am
Last seen: 6 years 3 months ago
0

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?

jasper_irakli's picture
Joined: Sep 9 2011 - 5:14am
Last seen: 7 years 6 months ago
0

and i have one more question

how to do align text of textField?

jasper_irakli's picture
Joined: Sep 9 2011 - 5:14am
Last seen: 7 years 6 months ago
1

Hello Everyone,

 

I resolved this problem with the styles option,

in the left menu REPORT INSPECTOR

STYLES

NEW

and config the properties field wiht this style

attach pictures with the description.

 

 

Code:
example
 
<style name="style_severidad">
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{SEVERIDAD}.equals("BAJA")]]></conditionExpression>
            <style mode="Opaque" backcolor="#FFFF00"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{SEVERIDAD}.equals("MEDIA")]]></conditionExpression>
            <style mode="Opaque" backcolor="#FFFF00"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{SEVERIDAD}.equals("ALTA")]]></conditionExpression>
            <style mode="Opaque" backcolor="#FFCC00"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{SEVERIDAD}.equals("CRITICA")]]></conditionExpression>
            <style mode="Opaque" backcolor="#FF3300"/>
        </conditionalStyle>
    </style>


Post Edited by elviejoguille at 04/27/2012 21:35
elviejoguille's picture
Joined: Jan 18 2012 - 5:43pm
Last seen: 4 years 4 months ago
Feedback