claudiobosticco Posted September 30, 2008 Share Posted September 30, 2008 I have a text field with evalutaion time=auto because it's a sum printed before the fields which contributes to the total value.I need to print the total in red if > 0 and green if < 0.normally I've used a conditional style to accomplish this, but the style's conditional expression evaluation seems to be evaluated "now", when the sum is zero.is it correct? Any workaround for this? ThanksClaudio Link to comment Share on other sites More sharing options...
szaharia Posted September 30, 2008 Share Posted September 30, 2008 Hi,you could use two separate fields, having the same position and characteristics, excepting the font color. In their printWhenCondition you can establish which of these fields gets visible and which not, according to the total's value. HTH,sanda Link to comment Share on other sites More sharing options...
claudiobosticco Posted October 10, 2008 Author Share Posted October 10, 2008 unfortunately, it seems that also "printWhen" expression is evaluated "now", when the sum is zero!I could use a string where conditionally insert styledText...but this means using a String type, so the field will not be recognized as number in Excel export. Link to comment Share on other sites More sharing options...
claudiobosticco Posted October 10, 2008 Author Share Posted October 10, 2008 also, using styled text, the style would be lost when exporting to Excel Link to comment Share on other sites More sharing options...
munga Posted March 9, 2009 Share Posted March 9, 2009 I am having the same problem, does anyone know of a solution? Link to comment Share on other sites More sharing options...
rogerjose81 Posted March 9, 2009 Share Posted March 9, 2009 Try using a customized scriptlet to achieve this. From the scriptlet you can access fields, parameters, etc. There you have some useful methods, beforeDetail, etc. Link to comment Share on other sites More sharing options...
munga Posted March 10, 2009 Share Posted March 10, 2009 From what I can tell from iReport a scriptlet can only access data objects i.e fields, variables and parameters; not the view object i.e TextField.If I'm wrong can you give me an example of changing the font colour in a scriptlet. Link to comment Share on other sites More sharing options...
rogerjose81 Posted March 10, 2009 Share Posted March 10, 2009 Of course, I mean to access the scriptlet from the conditional style. In the scriptlet you will manage the sum as you want. Link to comment Share on other sites More sharing options...
munga Posted March 11, 2009 Share Posted March 11, 2009 rogerjose81Wrote: Of course, I mean to access the scriptlet from the conditional style. In the scriptlet you will manage the sum as you want. There is no point is accessing the data before eval as the information has not been processed to determine the value, or after eval as It is not going to chagne the way it looks because the conditional sytle or printWhen expression has ready been evaluated.Again if I'm wrong can you give me an example of changing the font colour in a scriptlet. Link to comment Share on other sites More sharing options...
rogerjose81 Posted March 11, 2009 Share Posted March 11, 2009 I did not referred to change the font color in the scriptlet; it was about use the scriptlet just to know when to change the font. In any case, I would prefer to see code in this case. If you want create a tiny report to show your problem and post the code here.Post Edited by Roger Padilla at 03/11/09 21:09 Link to comment Share on other sites More sharing options...
munga Posted March 12, 2009 Share Posted March 12, 2009 I appreciate your help and I'll put together a small example over the weekend. Link to comment Share on other sites More sharing options...
munga Posted March 17, 2009 Share Posted March 17, 2009 OK here is a small example with a master and sub report. The subreport passes back a value to the master. The master using a conditional style sets the foreground red if the value is negative (at least it should).Notice the return value in the column header is not set red with a negative number, but the return value in the column footer is.To run the example first change the classpath in run_test.sh to your lib files then run./run_test.sh -100or ./run_test.sh 100 I hope the example explains it better than I can. 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