mdemetri2 Posted April 1, 2010 Share Posted April 1, 2010 I have been trying to figure out how to apply the Style Formatting to a field e.g. if it = 1 then background colour is green, 2 = organge etc.I have tried various exmaple that I did find and they dont work. Can someone post what should be the correct way?Many thanksDemetri Link to comment Share on other sites More sharing options...
slow Posted April 2, 2010 Share Posted April 2, 2010 in you have a finite set of option to create different styles try this:create a new stile:-set a name (ex: AlternativeStyle)-set the style option for the default look...-then add a new rule: new Boolean ($F{IT}.matches("1")) (or an integer expressione if you use integer...)-click on this rule and then set the new look...-create a new rule: new Boolean ($F{IT}.matches("2")) (or an integer expressione if you use integer...)- click on this rule and set another look......then apply this style ho a cell...in the jasper xml there is something like this: <style name="AlternativeStyle" isDefault="false" > <conditionalStyle> <conditionExpression><![CDATA[new Boolean ($F{IT}.matches("2"))]]></conditionExpression> <style name="AlternativeStyle" isDefault="false" backcolor="#33FF33" /> </conditionalStyle> <conditionalStyle> <conditionExpression><![CDATA[new Boolean ($F{IT}.matches("2"))]]></conditionExpression> <style name="AlternativeStyle" isDefault="false" backcolor="#FF0000" /> </conditionalStyle> <conditionalStyle> <conditionExpression><![CDATA[new Boolean ($F{IT}.matches("3"))]]></conditionExpression> <style name="AlternativeStyle" isDefault="false" backcolor="#0000CC" /> </conditionalStyle> </style> and the textfiled you applied the style to:<textField .....> <reportElement style="AlternativeStyle" ..../> ______________________________( if it works... KARMA points please! :) ) Link to comment Share on other sites More sharing options...
mdemetri2 Posted April 6, 2010 Author Share Posted April 6, 2010 Great that worked, but its odd as its the same as how I had it previously. I just re-did the sytle, I think the formatting on the fields was interferring. Thanks again. 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