Aligning multiple textfields in an individual column when next column stretches with overflow

I'm trying to align multiple textfields in a sigle detailcell of a table, when one of the other columns stretching with overflow.

Here is the current view : 

 

I could stretch the column which only has one element(the last one) and align in in the middle but I need to do the same for the first and third column as well.I need those multiple textfields centered in the middle.

Here is the table code:

<componentElement>
    <reportElement key="expenses" positionType="Float" x="0" y="20" width="842" height="43"
                   isRemoveLineWhenBlank="true" uuid="678aacb4-0394-4dcd-afff-aca01d21532f"/>
    <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components"
              xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
        <datasetRun subDataset="expenses" uuid="97187208-d2d4-4784-bf2b-9187ad9fdd61">
                <datasetParameter name="formatter">
                    <datasetParameterExpression>
                        <![CDATA[$P{formatter}]]>
                    </datasetParameterExpression>
                </datasetParameter>
                <dataSourceExpression>
                    <![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{expenses})]]>
                </dataSourceExpression>
        </datasetRun>
        <jr:column width="215" uuid="24abf29a-ac9f-4259-ad60-49db0d37de11">
            <jr:columnHeader style="table_CH" height="26" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="0" y="0" width="209" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63"/>
                    <textElement verticalAlignment="Middle"/>
                    <textFieldExpression>
                        <![CDATA[$R{pdf.label.expense}]]>
                    </textFieldExpression>
                </textField>
            </jr:columnHeader>
            <jr:detailCell style="table_TD" height="60" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_ordinary" positionType="Float"
                                   x="0" y="0" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Bottom"/>
                    <textFieldExpression>
                        <![CDATA[$F{categoryName}]]>
                    </textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_main" positionType="Float"
                                   x="0" y="20" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textFieldExpression><![CDATA[$F{merchantName}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_extra" positionType="Float"
                                   x="0" y="40" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Top"/>
                    <textFieldExpression>
                        <![CDATA[$P{formatter}.format($F{invoiceDate})]]>
                    </textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_ordinary" positionType="Float"
                                   x="0" y="0" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PER_DIEM" || $F{type} == "TRIP"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Bottom"/>
                    <textFieldExpression>
                        <![CDATA[$R{pdf.label.perDiem}]]>
                    </textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_main" positionType="Float"
                                   x="0" y="20" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PER_DIEM" || $F{type} == "TRIP"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textFieldExpression><![CDATA[$F{locationName}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_extra" positionType="Float"
                                   x="0" y="40" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PER_DIEM" || $F{type} == "TRIP"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Top"/>
                    <textFieldExpression>
                        <![CDATA[$P{formatter}.formatWithoutTime($F{fromDate}) + " - " + $P{formatter}.formatWithoutTime($F{toDate})]]>
                    </textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_ordinary" positionType="Float"
                                   x="0" y="0" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression><![CDATA[$F{type} == "MILEAGE"]]></printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Bottom"/>
                    <textFieldExpression><![CDATA[$R{pdf.label.mileage}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_main" positionType="Float"
                                   x="0" y="20" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression><![CDATA[$F{type} == "MILEAGE"]]></printWhenExpression>
                    </reportElement>
                    <textFieldExpression>
                        <![CDATA[msg($R{pdf.label.mileageExpenseInfo}, $F{distance},str("pdf.label.distance." + $F{distanceUnit}), str("pdf.label.vehicleType." + $F{vehicleType}))]]>
                    </textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_extra" positionType="Float"
                                   x="0" y="40" width="215" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression><![CDATA[$F{type} == "MILEAGE"]]></printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Top"/>
                    <textFieldExpression>
                        <![CDATA[$P{formatter}.formatRange($F{outboundDate}, $F{inboundDate})]]>
                    </textFieldExpression>
                </textField>
            </jr:detailCell>
        </jr:column>
        <jr:column width="164" uuid="b197f00a-4264-4292-8204-b0f006b0a813">
            <jr:columnHeader style="table_CH" height="26" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float"
                                   x="0" y="0" width="158" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63"/>
                    <textElement verticalAlignment="Middle"/>
                    <textFieldExpression>
                        <![CDATA[$R{pdf.label.details}]]>
                    </textFieldExpression>
                </textField>
            </jr:columnHeader>
            <jr:detailCell style="table_TD" height="60" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement isRemoveLineWhenBlank="true" style="table_TD_ordinary"
                                   positionType="Float" x="0" y="0" width="164" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Bottom"/>
                    <textFieldExpression><![CDATA[$F{purpose}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement isRemoveLineWhenBlank="true" style="table_TD_extra"
                                   positionType="Float" x="0" y="20" width="164" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT" && Boolean.FALSE.equals($F{reimbursable})]]>
                        </printWhenExpression>
                    </reportElement>
                    <textFieldExpression><![CDATA[$R{pdf.label.reimbursable}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement isRemoveLineWhenBlank="true"
                                   style="table_TD_extra" positionType="Float"
                                   x="0" y="40" width="164" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT" && Boolean.TRUE.equals($F{split})]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Top"/>
                    <textFieldExpression><![CDATA[$R{pdf.label.split}]]></textFieldExpression>
                </textField>
                 <textField isStretchWithOverflow="true">
                    <reportElement isRemoveLineWhenBlank="true" style="table_TD_ordinary"
                                   positionType="Float" x="0" y="0" width="164" height="60"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[($F{type} == "PER_DIEM"  || $F{type} == "TRIP") && Boolean.FALSE.equals($F{accommodationProvided})]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Middle"/>
                    <textFieldExpression>
                        <![CDATA[$R{pdf.label.accommodationProvided}]]>
                    </textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement isRemoveLineWhenBlank="true" style="table_TD_ordinary"
                                   positionType="Float" x="0" y="0" width="164" height="30"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression><![CDATA[$F{type} == "MILEAGE"]]></printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Bottom"/>
                    <textFieldExpression>
                        <![CDATA[msg($R{pdf.label.mileageDetailsInfo}, $F{origin},$F{destination})]]>
                    </textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement isRemoveLineWhenBlank="true" style="table_TD_extra"
                                   positionType="Float" x="0" y="30" width="164" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "MILEAGE"]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement verticalAlignment="Top"/>
                    <textFieldExpression>
                        <![CDATA[str("pdf.label.roundTrip." + $F{roundTrip})]]>
                    </textFieldExpression>
                </textField>
            </jr:detailCell>
        </jr:column>
        <jr:column width="54" uuid="dc8fad96-a75d-40b8-a99c-9ae858570755">
            <jr:columnHeader style="table_CH" height="26" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="0" y="0"
                                   width="48" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle"/>
                    <textFieldExpression>
                        <![CDATA[$R{pdf.label.vatDetails}]]>
                    </textFieldExpression>
                </textField>
            </jr:columnHeader>
            <jr:detailCell style="table_TD" height="60" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_extra" positionType="Float"
                                   x="0" y="0" width="54" height="30"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT" && Boolean.FALSE.equals($F{zeroVat})]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement textAlignment="Right" verticalAlignment="Bottom"/>
                    <textFieldExpression><![CDATA[$F{vatName}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="table_TD_ordinary" positionType="Float"
                                   x="0" y="30" width="54" height="30"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63">
                        <printWhenExpression>
                            <![CDATA[$F{type} == "PAYMENT" && Boolean.FALSE.equals($F{zeroVat})]]>
                        </printWhenExpression>
                    </reportElement>
                    <textElement textAlignment="Right" verticalAlignment="Top">
                        <font fontName="Apercu-Mono"/>
                    </textElement>
                    <textFieldExpression>
                        <![CDATA[$P{formatter}.format($F{vat})]]>
                    </textFieldExpression>
                </textField>
            </jr:detailCell>
        </jr:column>
        <jr:column width="85" uuid="ee471598-86df-4e82-9d6e-27c393d92f56">
            <jr:columnHeader  style="table_CH" height="26" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="0" y="0"
                                   width="79" height="20"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle"/>
                    <textFieldExpression>
                        <![CDATA[$R{pdf.label.gross}]]>
                    </textFieldExpression>
                </textField>
            </jr:columnHeader>
            <jr:detailCell style="table_TD" height="60" rowSpan="1">
                <textField isStretchWithOverflow="true">
                    <reportElement stretchType="RelativeToBandHeight" style="table_TD_amount"
                                   positionType="Float" x="0" y="0" width="85" height="60"
                                   uuid="1aaad190-cad6-4d1f-888c-2dd267a34a63"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle"/>
                    <textFieldExpression>
                        <![CDATA[$P{formatter}.format($F{settlementGross})]]>
                    </textFieldExpression>
                </textField>
            </jr:detailCell>
        </jr:column>
    </jr:table>
</componentElement>

I tried to use stretchType="RelativeToBandHeight" and stretchType="RelativeToTallestObject" for those fields but only first textfields in a column stretches and the rest becomes just invisible.

Thanks in advance!

pierrehakan's picture
Joined: Jul 26 2017 - 10:00am
Last seen: 4 years 7 months ago

1 Answer:

Hi Pierrehakan, I noticed that your picture was uploaded to this forum server, how did you do that? Every time I want to upload a picture I have to find a third party website.

This is what I did. I'm not sure if it satisfies your needs:

 

riodavid's picture
2433
Joined: Oct 27 2016 - 1:57am
Last seen: 4 years 4 months ago
Feedback
randomness