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:
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:
19 Answers:
Posted on August 18, 2006 at 6:55am
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.
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.
Posted on August 24, 2006 at 10:01pm
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
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
Posted on September 4, 2006 at 9:57am
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
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
Posted on September 4, 2006 at 10:19am
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
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
Posted on September 4, 2006 at 10:32am
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
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
Posted on September 4, 2006 at 10:38am
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
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
Posted on November 27, 2006 at 8:27pm
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? |