Thursday, February 13, 2014

Conditional Styles in crosstab

Conditional Styles 

Apply different formats/sytles to  fields based on different conditions . This can be done in two ways.

1.Using conditiona style
<style 
name="Background_Style"
isDefault="false"
>

<conditionalStyle>
<conditionExpression><![CDATA[new Boolean("($F{forecast}"=="true")]]></conditionExpression>
<style 
isDefault="false"
mode="Transparent"
backcolor="red"
>
</style>
</conditionalStyle>
</style>

use this style name in cellcontents of crosstab

<cellContents mode="Opaque" style="Background_Style">


2. Use condition statement


<bucketExpression class="java.lang.String">

<![CDATA[($F{forecast}=="true")?
"<style  mode='Transparent' backcolor='#1ABDC9' >"+ $F{monthName}.toString()+"</style>"
:
"<style  mode='Transparent' backcolor='#D4D00F' >"+ $F{monthName}.toString()+"</style>"]]>

</bucketExpression>




To apply conditional style

Create a style above and add the name in style property of crosstab or any other object.



No comments:

Post a Comment