setting backcolor at runtime for a text

Hi,
I am using Ireport1.2.0.
I want to change backcolor of my textfield dynamically at runtime.
Please do some favour for me its urgent.
thanx in advance
:huh: :huh:
rajesh's picture
151
Joined: Aug 8 2006 - 7:59pm
Last seen: 17 years 1 month ago

19 Answers:

hi,
Selecting the textfield,rightclicking, u will get list, select properties and in that select common tab, which consists background option,u can select ur choice color and can apply.
rgds,
anu.
smith's picture
103
Joined: Jul 19 2006 - 10:55pm
Last seen: 17 years 2 months ago
hi,
Selecting the textfield,rightclicking, u will get list, select properties and in that select common tab, which consists background option,u can select ur choice color and can apply.
rgds,
anu.
smith's picture
103
Joined: Jul 19 2006 - 10:55pm
Last seen: 17 years 2 months ago
I think that rajesh thought of setting the background color at runtime.
I have an idea for this: take 2 fields, one for each background color, and let the two field be displayed in change by setting the "display when expression" in a way that it is true every second time.
JulEgner's picture
1134
Joined: Aug 3 2006 - 10:59pm
Last seen: 17 years 1 month ago
thanx a lot my problem has been solved by using "print when expression"..
rajesh's picture
151
Joined: Aug 8 2006 - 7:59pm
Last seen: 17 years 1 month ago
Hello all,

The "printWhenExpression" is a good solution if you have 2 or 3 colors. What if I don't know my backcolor until runtime and it could be any color of the rainbow? Any solution for this problem?

Many thanks,

Remus


EDIT: at runtime to until runtime
Post edited by: rlacatus, at: 2006/08/25 14:30
rlacatus's picture
Joined: Aug 23 2006 - 6:31am
Last seen: 17 years 1 month ago
Hi, rajesh

i have the same thing i need to do... can you tell me please how you succeeded with the printWhenExpression?
It's kinda urgent, thanks a bunch.

Monica
Moniqa's picture
71
Joined: Aug 31 2006 - 10:03pm
Last seen: 17 years 1 month ago
rajesh wrote:
thanx a lot my problem has been solved by using "print when expression"..


It would be very nice when you share your wisdom here and show us how the "Print when expression" should look like ;)

Regards,
Darya
darya's picture
486
Joined: Jul 26 2006 - 7:06pm
Last seen: 17 years 2 months ago
I've used 2 textfields on the same location with the same expression, each having its corresponding backcolor.

Then, we have the variable in iReport called $VREPORT_COUNT} that is incremented at every record/line.

So for the textfield with the backcolor that i want to display at the first line and then every 2nd alternation, i put in PrintWhenExpression:
new Boolean($V{REPORT_COUNT}.intValue()%2==0)

and for the textfield with the backcolor that i want to display at the 2nd line and then at every 2nd alternation, i put in PrintWhenExpression:
new Boolean($V{REPORT_COUNT}.intValue()%2==1)

Hope this helps for you.

Monica
Moniqa's picture
71
Joined: Aug 31 2006 - 10:03pm
Last seen: 17 years 1 month ago
Hi Monika,

Thanks a lot for the tip. Can you tell me what iReport version you use? I use iReport-1.1.0 and there is no way to set the backcolor :unsure: .

Regards,
Darya
darya's picture
486
Joined: Jul 26 2006 - 7:06pm
Last seen: 17 years 2 months ago
Hi Monika,

Thanks a lot for the tip. Can you tell me what iReport version you use? I use iReport-1.1.0 and there is no way to set the backcolor :unsure: .

Regards,
Darya
darya's picture
486
Joined: Jul 26 2006 - 7:06pm
Last seen: 17 years 2 months ago
The best solution is using a conditional stylesheet.

Giulio
giulio's picture
74195
Joined: Jan 2 2007 - 4:15pm
Last seen: 6 days 3 hours ago
What do you mean by conditional stylesheet :sick: . I could follow Monika. But I don't know how a conditional stylesheet works here.

Isn't iReport creating the whole thing?

Anyway Monika's way sounds good for me, I only have the problem that I don't know how to set the background color for my 2nd rectangle. At least not with iReport-1.1.0 :(

Is it possible at all. Or do I have to add the background color by hand in iReports' created .jrxml file?

I can't simply upgrade to iReports-1.2.5 because I depend on JasperReports jasperreports-1.1.1.jar JAR file and have no authority to change that :whistle: .

Regards,
Darya
darya's picture
486
Joined: Jul 26 2006 - 7:06pm
Last seen: 17 years 2 months ago
Simply pick a color for the background in the element properties window.
Be sure the element is not set to be transparent.

Giulio
giulio's picture
74195
Joined: Jan 2 2007 - 4:15pm
Last seen: 6 days 3 hours ago
conditionalStyle sound more intelligent :woohoo: (sorry Monika ;) , I'll use your approach as fallback in case Giulio's apprach doesn't work for me.)

Giulio, can you elaborate a little bit more what I need to do?

Regards,
Darya
darya's picture
486
Joined: Jul 26 2006 - 7:06pm
Last seen: 17 years 2 months ago
Giulio, you forgot that I stuck with iReport-1.1.0

What you say seems to work with the latest iReport-1.2.5 release and I am not sure whether I can use this latest release because I depend on jasperreports-1.1.1.jar.

Anyway, I should give it a try first.

Regards,
Darya
darya's picture
486
Joined: Jul 26 2006 - 7:06pm
Last seen: 17 years 2 months ago
I think you can use your reports with jr 1.2.5 without recompile your reports and/or your application.

Anyway the steps are:

1. Be sure the background of your element is not set (if it is, you should see the background property displayed in bold in the element properties sheet: press the special button to reset this propety (it's the button with a lottle crown.

2. In the styles window, create a new style and set for this style the background property (this will be the default value for the background).

3. Drag and drop the style over your element

4. Back to the style, and add a condition in the conditions list. For each condition you can set a different value for the background property.

Hope it's clear.

Giulio
giulio's picture
74195
Joined: Jan 2 2007 - 4:15pm
Last seen: 6 days 3 hours ago
Thanks Giulio,

I'll give it a try and post my feedback later here.

Regards,
Darya
darya's picture
486
Joined: Jul 26 2006 - 7:06pm
Last seen: 17 years 2 months ago
new Boolean("OK".equalsIgnoreCase($P{execution}))
use such type of expression in print when expression field.
rajesh's picture
151
Joined: Aug 8 2006 - 7:59pm
Last seen: 17 years 1 month ago
I want to change the background colour to show results of the search - for example, highlight all elements that contain the word "foobar". Is there something I can put into the conditional expression that applies to all fields? I mean, it is not very flexible to have something like
Code:
new Boolean($F{f1}.equals("foobar"«»)</td></tr></tbody></table> for every field I have in the report. Plus, I want to include static field in the search too.<br />
<br />
If this is not possible, can I modify the style from Java of individual JRPrintElement contained in the JasperPrint object?
eco's picture
eco
27
Joined: Nov 27 2006 - 3:34am
Last seen: 1 year 8 months ago
Feedback
randomness