Text field shading every odd line

0

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";

I want to shade every second line like this:

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>

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

dunham's picture
36
Joined: Oct 18 2013 - 6:57am
Last seen: 1 month 1 week ago

2 Answers:

0

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

trvpseudo's picture
Joined: Jan 30 2019 - 11:02pm
Last seen: 10 hours 15 min ago
0

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

C-Box's picture
1736
Joined: Jul 19 2006 - 5:58pm
Last seen: 7 hours 26 sec ago
Feedback
randomness