Dynamic row height based on data in table and make

2019-08-16 18:16发布

问题:

Dynamic row height based on data in table and make it for all the column

I am working with Jaspersoft ireport designer 4.7.0. I have a table with 3 columns and dynamically set the table row height as per data using https://community.jaspersoft.com/wiki/dynamically-set-table-row-height-data. The requirement   here is,I want to make all the table cell  to the same height as the tallest object. Currently it works only for the row which has the tallest object.PFA the .jrxml.

I want the second row also to be as of same height of the first row i.e highest object of the table.Please help.

`<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report3" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f32dfce1-c0d4-4f20-b896-653e7497d7ba">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="tabeDataSet" uuid="46e73a3d-e883-4c74-a062-6984cc6dac58">
        <field name="id" class="java.lang.String"/>
        <field name="city" class="java.lang.String"/>
        <field name="street" class="java.lang.String"/>
    </subDataset>
    <parameter name="tableData" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <detail>
        <band height="260">
            <componentElement>
                <reportElement uuid="d30c2063-0208-47b7-999d-567dac8c80f6" key="table 1" positionType="Float" stretchType="RelativeToTallestObject" x="72" y="53" width="395" height="93"/>
                <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" whenNoDataType="AllSectionsNoDetail">
                    <datasetRun subDataset="tabeDataSet" uuid="972de646-f6e5-4a89-bf2e-50a77a7e0172">
                        <dataSourceExpression><![CDATA[$P{tableData}]]></dataSourceExpression>
                    </datasetRun>
                    <jr:column uuid="1c395685-a4d8-46f4-a6a8-5deeb33f758a" width="90">
                        <jr:tableHeader height="30" rowSpan="1">
                            <box leftPadding="1">
                                <pen lineWidth="0.5"/>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <staticText>
                                <reportElement uuid="f7e661e3-d38d-4e46-aba7-2a54af94a88c" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="89" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font isBold="true"/>
                                </textElement>
                                <text><![CDATA[ID]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="20" rowSpan="1">
                            <box leftPadding="1">
                                <pen lineWidth="0.5"/>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement uuid="55b324c7-ec61-49f0-9565-2f7d5c95e3b5" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="89" height="20" isPrintInFirstWholeBand="true"/>
                                <textElement verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column uuid="1f4dcc0c-d37b-41c9-94c0-a59de8c07020" width="90">
                        <jr:tableHeader height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="0.5"/>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <staticText>
                                <reportElement uuid="5a357a85-1647-47fb-8db2-63e63b281af1" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="90" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font isBold="true"/>
                                </textElement>
                                <text><![CDATA[City]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="20" rowSpan="1">
                            <box>
                                <pen lineWidth="0.5"/>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement uuid="aed9b850-e496-4394-b1a7-0ffae688b00b" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="90" height="20" isPrintInFirstWholeBand="true"/>
                                <textElement verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column uuid="2ea2acdc-b06e-4acf-93cc-726ef96fa1e3" width="90">
                        <jr:tableHeader height="30" rowSpan="1">
                            <box>
                                <pen lineWidth="0.5"/>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <staticText>
                                <reportElement uuid="303b9cd4-aa31-449d-8a4c-f609e920da1f" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="90" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font isBold="true"/>
                                </textElement>
                                <text><![CDATA[Street]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell height="20" rowSpan="1">
                            <box>
                                <pen lineWidth="0.5"/>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement uuid="04dcda99-69b7-408c-b0a7-a63a57c50072" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="90" height="20" isPrintInFirstWholeBand="true"/>
                                <textElement verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$F{street}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
            <staticText>
                <reportElement uuid="e891c43a-4b72-40d7-8846-acaa4a4f045e" x="58" y="12" width="100" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Address]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="5ce33e92-430d-4219-8fe4-3dbaf8b55dfc" x="185" y="193" width="100" height="20"/>
                <textElement/>
                <text><![CDATA[here1]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>
`