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

alternate background color for each record


ktrinad

Recommended Posts

By: Olivier - opoppon

alternate background color for each record

2003-11-24 08:45

Hi,

 

I have seen a screenshot from the iReport page (the one about custom JRDataSource I think) which show a simple page where the coloring for each row is different (white and pink on the PDF).

I would like to know if this is acheived easily by iReport or the "hard way" (counter, "printWhenExpression"...)

 

Cheers,

 

Olivier

 

 

 

 

By: Olivier - opoppon

RE: alternate background color for each record

2003-11-25 05:44

What I have done is the following:

Make my JRDataSource return its current index when I use the field "counter".

now, it is a bit verbose, because I am using a printWhenExpression for each field (in the reportElement tag).

So I duplicate each textfield twice, one reportElement with "#FFFFFF" background with printWhenExpression at count%2==0 and the other textfield with reportElement with "#000000" background with printWhenExpression at count%2!=0

 

Is this correct of is there something "lighter" ?

 

Cheers

 

Olivier

 

 

 

 

By: Giulio Toffoli - gt78

RE: alternate background color for each record

2003-11-25 09:31

You can simply put two coloured rectangles that will be our background. Send this rectangles to back, and use your formula for printWhenExpression only for the rectangle in front.

All textfields must be over this rectangles and must be "transparent".

 

The idea is to hide one of two rectangle to show on the back (as a background) the first rectangle. When the first is not hide, the second is covered by this and the background effect change.

All textfields will be printed over this two rectangles.

In this way you can use images instead a simple rectangle, and make some very pretty effects.

 

Giulio

 

 

 

 

By: Olivier - opoppon

RE: alternate background color for each record

2003-12-03 03:03

Hi Giulio,

 

Sorry to reply so late, I integrating bit of jasper into my code.

 

I like the idea about switching on/off rectangles rather than each field. But as I understand it, there would be a "Z-order" field in a report element ?

When you talk about putting an element in the back and other in the front, is this what you are thinking.

 

I didn't see such field, is there another way to do so ?

 

thanks,

 

Olivier

 

 

 

 

By: Giulio Toffoli - gt78

RE: alternate background color for each record

2003-12-03 06:46

the Z order is defined by the order in wich an element appear in the XML. You can see this order in the elements tree.

 

Giulio

 

 

 

 

By: Giulio Toffoli - gt78

RE: alternate background color for each record

2003-11-24 12:11

You can find the hard way in this forum.

(the hard way is really simplest that you think).

 

If you don't find it, post a new message to this thread.

 

Giulio

 

 

 

 

By: Jeanpaul - jpfinne

RE: alternate background color for each record

2004-06-07 03:29

Hi Giulio,

 

Could you explain (or give a link to) the hard way ?

 

I could'nt find it.

 

Jean-Paul

 

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: alternate background color for each record

2004-06-07 05:30

 

I don't remember it. But why use an hard way when you can achive the same result using a simpler way :-) ?

 

Giulio

 

 

 

 

By: Jeanpaul - jpfinne

RE: alternate background color for each record

2004-06-07 14:37

I thought the hard way could be a generic way to do it.

 

I have to convert reports from crystal report. In crystal report there are formulas for about everything : field height, tootip, hyperlink, foreground color, left,right,top and bottom border width, fonts ....

 

I agree there are too many formulas. The problem is that jasper has too few.

 

Could the hard way use scriplet to change dynamically some properties ? I'm mostly interested in foreground/background color and font attributes (italic or not).

 

I know the solution with the use of printWhenExpression.

I find it a bit cumbersome. I have a report that use 2 expressions to control the italic property and background color. I have to use 4 fields to do the same with jasper. This sample is a bit extreme but I have to convince a client to switch from crystal report to jasper and ireport.

 

Ireport could better handle superposing fields. Here are some suggestions:

* The use of layers for fields with the same printWhenExpression formula could allow easy navigation between them with A combobox or a slider.

* Another solution: create a copy of a field inside a group of superposing fields. When I edit the properties of the group, the dialog box shows the shared properties. When I edit the properties of one field I only edit the differences (like printWhenExpression and background color). When I move or resize one the field in the group, the others are synchronized.

* Better handlind of z-order. Use drag and drop instead of Move up,down up.

* Inside a band the nesting of fields could be shown with a tree. A field entirely contained inside a field is a child in the tree. Fields with the same position and size are child of a group node.

 

Anyway, thank you a lot for all the improvements and all the answer in this forum.

 

Jean-Paul

 

 

 

 

By: Jeanpaul - jpfinne

RE: alternate background color for each record

2004-06-08 13:54

Some of my suggestions seem related to ElementGroup...

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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