Jump to content
Changes to the Jaspersoft community edition download ×

alternate row color using styles


sdandekar

Recommended Posts

I am using iReport3.5.2 and have a repot where Iwould like to have alternate row colors. I have searched this forum and googled it, found several alternatives. In my case I found that it could be done with styles applied to a frame. However, when I applied it in my report, it did not work either in PDF or on the Excel or RTF outputs.

What do I need to do to get the alternate row color?


Code:
    <style name="EvenOddRowStyle" isDefault="false" backcolor="#DFE5FF">        <conditionalStyle>            <conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue() %2 == 0)]]></conditionExpression>            <style isDefault="false"/>        </conditionalStyle>    </style>    <detail>        <band height="20">            <frame>                <reportElement style="EvenOddRowStyle" x="0" y="0" width="692" height="20"/>                <textField isBlankWhenNull="true">                    <reportElement x="223" y="0" width="66" height="20" forecolor="#404040" backcolor="#FFFFFF"/>                    <textElement textAlignment="Center" verticalAlignment="Middle" markup="styled">                        <font fontName="Arial" size="10"/>                    </textElement>                    <textFieldExpression class="java.lang.String"><![CDATA[$F{sumItems}]]></textFieldExpression>                </textField>            </frame>        </band>    </detail>
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

You have to write properly the conditional style. The backcolor should be set within the conditional style itself, or it gets applied everywhere.

HTH,

sanda

Code:
<style name="EvenOddRowStyle" isDefault="false" mode="Opaque"> <conditionalStyle>  <conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue() %2 == 0)]]></conditionExpression>  <style backcolor="#DFE5FF"/> </conditionalStyle></style>
Link to comment
Share on other sites

  • 3 years 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...