Jump to content
We've recently updated our Privacy Statement, available here ×

alternate row color


jeans

Recommended Posts

  • Replies 14
  • Created
  • Last Reply

Top Posters In This Topic

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

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.java

Errors 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.jpg

Post edited by: tmcquoid, at: 2007/01/04 19:29

Link to comment
Share on other sites

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

  • 2 months later...
  • 2 months later...
  • 1 month later...

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

  • 11 months later...
  • 4 months later...

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

  • 2 months later...
  • 2 weeks later...

anish
Wrote:

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

  • 6 years later...

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

  • 4 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...