I've add a conditionnal style to my report for alternate row style like this :
<style name="tab_page_4">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 1]]></conditionExpression>
<style forecolor="#FFFFFF" backcolor="#E7ECF4"/>
</conditionalStyle>
</style>
<reportElement key="textField" style="tab_page_4" mode="Opaque" x="11" y="5" width="94" height="15" forecolor="#00597C" backcolor="#FFFFFF" uuid="4ea6f9a0-d1c8-42f0-8ae4-7c9780fcfe3d"/>
When i generate my report, the custom style doesnt work.
What i've forgot ?
When using conditional styles, it is important to remove all style data in the element. This means that in this case the elements mode
, forecolor
and backcolor
should be removed so that the style is used.
It is possible to set e.g. the forecolor
on an element when using a conditional to set the forecolor explicitly for this element. But usually all coloring will happen with the conditional style.
EDIT
As Alex K pointed out, make sure the conditional style also sets mode="Opaque"
:
<style name="tab_page_4" mode="Opaque">
....
</style>
Or if using conditional styles:
<conditionalStyle>
<conditionExpression>...</conditionExpression>
<style mode="Opaque" .../>
</conditionalStyle>