Jump to content

Recommended Posts

Posted

I'm working on a Jasper report and currently, I use the zebra style for my table detail cell which alternates row color for every other row

<style name="Zebra" mode="Opaque">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 1]]></conditionExpression>
<style backcolor="#EFEFEF"/>
</conditionalStyle>
</style>
...
<jr:detailCell style="Zebra" height="49" rowSpan="1">
...
But I want to change this rule so that the color of the row is determined by a value in my table row. So if the JSONArray I use in the table is named CLIENT_DATA and each JSONObject in my CLIENT_DATA has a string field called ROW_COLOR, how do I set table row color based on my string value?

 

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

You can use conditional styling.

Add a new Style ,"rowStyle"  to the report

Add conditional style to the style(rowStyle) that you created now .

Give the appropriate condition for which the background color should change in the condition expression property. (For ex: $F{STATUS}.equals( "Completed" ) ). Add condition for each color required, like Status is "InProgres", "pending" etc

Now set the BackColor of this style  to the appropriate color

Now set the style "rowStyle" for the field for which the bg should change dynamically

 

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