How To: Highlight odd-even rows in a BIRT report
I haven’t been able to find an obvious way to highlight odd-even rows with different background colors using birt… I was expecting to find something in the UI to click and choose colors, but I’ve found none.
The solution is in the Highlight tab of the row properties. Even better, create an style in the Library. Here you can specify the color and font to use when an specific condition is met.
To change the background depending on if it is an even or odd row, use the modulus operator, as seen in the following picture.
This way is more powerful than a simpler color picker. Why? Because you can have complex highlighting based on several conditions. For a different report I needed to highlight the row in green, yellow or red (depending on a given threshold) but also keep the odd-even highlighting to make it more readable.
The solution… create 2*n rules, checking for the odd-even case and the threshold case, as depicted below:
Using this technique, complex highlighting rules can be used.
(N.B.: I think I recall reading somewhere that there’s a default style for odd-even rows… but I was too lazy to check that)