william.roberts Posted June 24, 2014 Posted June 24, 2014 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?
AnnMary.Thomas Posted June 25, 2014 Posted June 25, 2014 You can use conditional styling.Add a new Style ,"rowStyle" to the reportAdd 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" etcNow set the BackColor of this style to the appropriate colorNow set the style "rowStyle" for the field for which the bg should change dynamically
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now