Jump to content
We've recently updated our Privacy Statement, available here ×

Text field shading every odd line


dunham

Recommended Posts

I have a "Text Field" that reads from a Map parameter "number" defined like this

String number = "first line n second line n third line";[/code]

I want to shade every second line like this:

line.png.03a75b6eb6a5625c4a61a34f90cd3476.png

Here is the definition of the "Text Field"

  <textField isStretchWithOverflow="true" isBlankWhenNull="true">                <reportElement x="110" y="77" width="110" height="11"/>                <textElement verticalAlignment="Middle">                    <font fontName="SansSerif" size="8" isBold="false"/>                    <paragraph lineSpacing="Fixed" lineSpacingSize="10.0" leftIndent="2"/>                </textElement>                <textFieldExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("number")]]></textFieldExpression>            </textField>[/code]

-> Is there a way to define it so that every odd line in the text field has a background color?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

you can use table in basic element.

in the table style setup, remove all header and footer (if u dont need it). you can differ the odd row color by checking "use alternated detail rows background"

 

this one help me when i havent found the table element

https://community.jaspersoft.com/questions/542320/different-colour-alternate-rows

 

hope that helps, cheers!

TV

Link to comment
Share on other sites

  • 3 weeks later...

You could also use a Conditional Style with just an expression like $V{REPORT_COUNT} % 2 == 0 to set another background color to your textfields. (be aware, not to define a separate background colör at textfield level itself just at the style level!)

Then you wont need a extra table component. 

hth + regards

C-Box

Link to comment
Share on other sites

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