someguy51 Posted July 27, 2006 Share Posted July 27, 2006 Hi, Is it possible to conditionally change the font in a textfield? For example, I want to bold a textfield when a flag is true and have the same textfield not bolded when the flag is false. Thanks Link to comment Share on other sites More sharing options...
bhaugland Posted July 27, 2006 Share Posted July 27, 2006 Yes it is but you need two text fields. One should be set for one font, the other set for the other font. Both text fields will occupy the same space on the report. Set the print when expression for both text fields to be based on the flag settings. ex. flag == true. This way when the report is run the correct font will print based on the condition. Link to comment Share on other sites More sharing options...
someguy51 Posted July 27, 2006 Author Share Posted July 27, 2006 Thanks bhaugland. That got the job done. Link to comment Share on other sites More sharing options...
SoS Posted July 27, 2006 Share Posted July 27, 2006 someguy51 wrote:Hi,Is it possible to conditionally change the font in a textfield? For example, I want to bold a textfield when a flag is true and have the same textfield not bolded when the flag is false.Thanks You don't need to have 2 textfields for this.Just use the condtional expression in the textfields expression. This expression changes the current style if deger1 paramater is equal to isim field. I hope it helps. Code:($F{isim}.equals($P{deger1}) ? "<style isBold='TRUE' forecolor='red' size='20' pdfFontName='Helvetica-Bold'>" +$F{isim}+"</style>" : $F{isim} ) Link to comment Share on other sites More sharing options...
someguy51 Posted July 27, 2006 Author Share Posted July 27, 2006 Hi SoS, Thanks for your reply. It would be more convienient to use only one textfield so I tried your idea. Here is my code in the textfield expression: Code:(SL2.isReminderAlarm($F{reminddaysn}, $F{receivedon}, $F{remindon}).booleanValue()) ? "<style isBold='TRUE' pdfFontName='Helvetica-Bold'>" + $F{typedtq} + "</style>": $F{typedtq} When "isReminderAlarm" returned false it just printed "typedtq" as expected. However, when it returned true it actually printed the text "<style..." instead of changing the font. Perhaps the version we are using is too old? It is iReports 1.2.3 Any ideas? Thanks,someguy51 Link to comment Share on other sites More sharing options...
SoS Posted July 28, 2006 Share Posted July 28, 2006 i first used it with 1.2.4 (both jasper & ireport) and now i m using with 1.2.5 with no problem at all. HTML & PDF exports were ok. As you wrote, you might try some newer versions i guess. Also check if you enabled StyledText option for that textfield element. :side:Post edited by: SoS, at: 2006/07/28 06:19 Link to comment Share on other sites More sharing options...
someguy51 Posted July 31, 2006 Author Share Posted July 31, 2006 Hi SoS, I got it to work. The StyledText option was not enabled. B) Thank you very much! Link to comment Share on other sites More sharing options...
SoS Posted August 1, 2006 Share Posted August 1, 2006 you are welcome :cheer: Link to comment Share on other sites More sharing options...
amm1234 Posted July 18, 2007 Share Posted July 18, 2007 i have the same problem too.. but just check the condition of styledtext in the properties all and eavry thing will be ok..Post edited by: amm1234, at: 2007/07/18 10:28 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