jeans Posted December 27, 2006 Share Posted December 27, 2006 hi! im a newbie in jasperreport/iReport. is there anybody knows how to make alternate row colors in iReport's subreport? thanks in advance! Link to comment Share on other sites More sharing options...
jmurray Posted December 28, 2006 Share Posted December 28, 2006 Set up a new java.lang.Integer variable called BACKGROUND. Set its Calculation Type to DistinctCount, Reset type to None, Increment type to None, Variable Expression to a field that will always contain unique values (eg. $F{PortNumber} ), and an Initial Value Expression of new java.lang.Integer(0). That will give you an auto-incrementing variable. In the Detail section make sure all the existing elements are set to Transparent. Now in the Detail section of your report create a new Static Text box. Size it to cover the full extents of the detail section. If you are using multiple columns size it to the full extent of just one column. Set its background colour to be whatever you want it to be. Put a single space in the Static Text area. To make it toggle on and off you use a Print When expression based on your BACKGROUND variable. Set it to be new java.lang.Boolean(($V{BACKGROUND}.intValue() % 2)==1) Now all you need to do is send it to the back. Under the Format Menu choose the Send to Back option, and your done.Post edited by: jmurray, at: 2006/12/27 22:37 Link to comment Share on other sites More sharing options...
tmcquoid Posted January 5, 2007 Share Posted January 5, 2007 I believe that I followed your instructions explicitly, but I get the following error statement: Compiling to file... .test_running_balance.jasper -> C:Program FilesJasperSoftiReport-1.2.8test_running_balance.javaErrors compiling .test_running_balance.jasper!it.businesslogic.ireport.ReportClassLoader@1ca265 net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Cannot cast from int to Integer value = (java.lang.Integer)(0); <--------------------> 2. Cannot cast from boolean to Boolean value = (java.lang.Boolean)((((java.lang.Integer)variable_BACKGROUND.getValue()).intValue() % 2)==1); <------------------------------------------------------------------------------------------> 3. Cannot cast from int to Integer value = (java.lang.Integer)(0); <--------------------> 4. Cannot cast from boolean to Boolean value = (java.lang.Boolean)((((java.lang.Integer)variable_BACKGROUND.getOldValue()).intValue() % 2)==1); <---------------------------------------------------------------------------------------------> 5. Cannot cast from int to Integer value = (java.lang.Integer)(0); <--------------------> 6. Cannot cast from boolean to Boolean value = (java.lang.Boolean)((((java.lang.Integer)variable_BACKGROUND.getEstimatedValue()).intValue() % 2)==1); <---------------------------------------------------------------------------------------------------> 6 errors at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:193) at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:105) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:127) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:109) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:510) at java.lang.Thread.run(Unknown Source) Compilation running time : 17 attached is a picture of detail field and static field properties. What am I doing wrong. tmcquoid size=357]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/AltColorSnip2.jpgPost edited by: tmcquoid, at: 2007/01/04 19:29 Link to comment Share on other sites More sharing options...
jmurray Posted January 5, 2007 Share Posted January 5, 2007 Your Print When Expression is not correctly defined. It should read: new java.lang.Boolean(($V{BACKGROUND}.intValue() % 2)==1) As for the other error it looks like you didn't cast your Initial Value Expression as Integer, but just entered 0. Make sure the expression reads: new java.lang.Integer(0)Post edited by: jmurray, at: 2007/01/04 19:42 Link to comment Share on other sites More sharing options...
jasperNoob Posted March 14, 2007 Share Posted March 14, 2007 thanks jMurray for the detailed solution :) If only someone could give a similar detailed solution for translating my report labels into chinese :P at least take a look at my problem here :http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=view&id=22433&catid=9Post edited by: jasperNoob, at: 2007/03/14 13:21 Link to comment Share on other sites More sharing options...
rclarke88 Posted May 16, 2007 Share Posted May 16, 2007 Excellent solution jmurray - worked perfectly the first time. Link to comment Share on other sites More sharing options...
anish Posted July 3, 2007 Share Posted July 3, 2007 hi all... can some one help me in the following lines... ------- Now all you need to do is send it to the back. Under the Format Menu choose the Send to Back option, and your done. ----- where is the format menu in jasper assistant... ?? plz help . Thanks in advance Link to comment Share on other sites More sharing options...
codyjasperForge Posted July 3, 2007 Share Posted July 3, 2007 Anish, You simply need to right click within iReport and choose the 'Send to back' option from the available list. There should also be an option under the 'Format' menu to do so. Also, make sure that you have the correct version that supports this functionality. Link to comment Share on other sites More sharing options...
anish Posted July 4, 2007 Share Posted July 4, 2007 thank you buddy... it works.. regards,Anish Link to comment Share on other sites More sharing options...
jonnazs Posted June 7, 2008 Share Posted June 7, 2008 Hello, I'm trying to show my report via html, but I heard that jasper does not suport overlapping, what can i do? :dry: Link to comment Share on other sites More sharing options...
ianpottier Posted October 9, 2008 Share Posted October 9, 2008 Hi Jonnazs,I also think that it's a shame that overlapping is not functionning with HTML, what's the point in JasperServer without HTML?Anyways, if you copy-paste the fields in your row twice above each other and set a rule for even AND uneven rows as described before, you should be able to make it work. Of course one set of fields should have a background color and the other none (or a different color). Result is somewhat acceptable, but this should be out of the box! Link to comment Share on other sites More sharing options...
vmlinux Posted January 5, 2009 Share Posted January 5, 2009 Nevermind, the problem I was having was an iReport issue, and was resolved by restarting it. Post Edited by David Carroll at 01/05/09 20:22 Link to comment Share on other sites More sharing options...
yaroslav Posted January 20, 2009 Share Posted January 20, 2009 anishWrote: hi all... can some one help me in the following lines... ------- Now all you need to do is send it to the back. Under the Format Menu choose the Send to Back option, and your done. ----- where is the format menu in jasper assistant... ?? plz help . Thanks in advance I have the same problem. Can't find the Send to Back option.Please help.Ireport 3.1.0 Link to comment Share on other sites More sharing options...
agilaganesh92 Posted February 4, 2015 Share Posted February 4, 2015 Error filling print... Error evaluating expression : Source text : java.lang.Boolean(($V{BACKGROUND}.intValue() % 2)==1) net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : java.lang.Boolean(($V{BACKGROUND}.intValue() % 2)==1) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559) at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:966) at net.sf.jasperreports.engine.fill.JRFillElement.evaluatePrintWhenExpression(JRFillElement.java:759) at net.sf.jasperreports.engine.fill.JRFillStaticText.evaluate(JRFillStaticText.java:110) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:455) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2044) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:778) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:288) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: groovy.lang.MissingPropertyException: No such property: java for class: report4_1423073212155_266558 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:86) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231) at report4_1423073212155_266558.evaluate(calculator_report4_1423073212155_266558:181) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190) ... 20 more Print not filled. Try to use an EmptyDataSource...jummuray when i tried as like what you said am getting the following error. please help me to fix this error. Thanks in advance Link to comment Share on other sites More sharing options...
afaquecena Posted June 17, 2015 Share Posted June 17, 2015 1) Simply take a rectangle set its print when expression as $V{REPORT_COUNT}%2==0 2) keep all the fields inside that rectangle in detail band 3) choose appropriate backcolor for rectangle 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