railsgeek Posted March 12, 2007 Share Posted March 12, 2007 Hello, I need to set a style based on the textField value for many textFields. I need to do it generic, not setting each $F{name_of_field} style for each textField cell. Link to comment Share on other sites More sharing options...
Solution mmflynn Posted June 20, 2007 Solution Share Posted June 20, 2007 I found your post while doing a little work on styles myself. Better late than never? You should be able to solve your problem by creating a default style with a conditional expression. E.g.:1. Create a style named "normal" (or whatever)2. Click Default style3. Add a Style Condition4. Write a boolean expression that would result "true" for all the fields you want to apply the style to. (I'm not very good at this part...)5. Apply the new style to the fields you want to evaluate. I'm not an expert, but this might help! Mary Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted June 21, 2007 Share Posted June 21, 2007 hm, this is a good question. If I understand, you want a "dynamic" evaluation expression for your conditional style, based on the textfield value (that can be calculated based on different report objects, like fields, parameters, etc...). Like a generic style for numeri values...Essentially this is not possible in JR: when you define the condition, the condition itself is compiled in a java expression that is independent by the element to which the style will be applied. This means that even if you find a way to parametrise the "result" of your textfield, there is no way to set a condition on his style dynamically. The best way (already suggested) is create a parent style and specialize children styles for each expression you need as condition. Giulio Link to comment Share on other sites More sharing options...
jimcmic.ca Posted May 16, 2012 Share Posted May 16, 2012 I would like to create a style which in English would read:If the value of the field I am in is less than zero, change the color to REDThen when I apply that style to 10 number fields, I do not have to create a conditional style for each field.If I had 3 fields, named "MEXICO_PROFIT", "USA_PROFIT", "CANADA_PROFIT", I currently see needing 3 conditional styles:MEXICO_PROFIT_STYLE$F{MEXICO_PROFIT} < 0foreground REDUSA_PROFIT_STYLE$F{USA_PROFIT} < 0foreground REDCANADA_PROFIT_STYLE$F{CANADA_PROFIT} < 0foreground REDWhat I want is something like this, which I could apply to any numeric field:NEGATIVE_RED_STYLE$F{*} < 0In this case $F{*} means the current field.In Java you have the "this" object to get yourself, is there no way inside a conditional style expression to get the field where the style is being applied to? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now