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

Jaspersoft Studio: Table with dynamic detailCell height


mateusz.korga

Recommended Posts

Hi everyone

I'm building dynamic table when row in table looks diferent depends on details.

My detailCell in table can consists of several rows. Depends if the condition is met the row is displayed. Minimum one row - max 5:

What i want to achieve is to change thedetailCell height dynamically depends on how many textFields are applied (met condidition). I was able to hide rows, but the row wasnt removed. Was left with blank space.

<componentElement>
                    <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="some" uuid="5f02b7d5-8a2d-4e56-ac3f-4d10e0999c0c">
                            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("some")]]></dataSourceExpression>
                        </datasetRun>
                        <jr:column width="110" uuid="4845b8fc-d3a8-4ad2-b74e-932390d59a44">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
                            <jr:detailCell height="50">
                                <textField>
                                    <reportElement  x="0" y="0" width="110" height="25" uuid="7874686b-5545-4a53-bcd2-1249ba1b2346"/>
                                    <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
                                </textField>
                                <textField isBlankWhenNull="true">
                                    <reportElement x="0" y="25" width="110" height="25" isRemoveLineWhenBlank="true" uuid="3a415bb2-5e26-4e44-9b7b-6dca18eeb73f">
                                        <printWhenExpression><![CDATA[$F{amount}.compareTo(BigDecimal.ZERO) != 0]]></printWhenExpression>
                                    </reportElement>
                                    <textElement markup="none"/>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="130" uuid="e582b757-071e-4929-a8e6-c92b23844ec0">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
                            <jr:detailCell height="50">
                                <textField>
                                    <reportElement x="0" y="0" width="130" height="25" uuid="03353833-4a36-48c0-8621-c289ac7957cb"/>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                                <textField isBlankWhenNull="true">
                                    <reportElement x="0" y="25" width="130" height="25" isRemoveLineWhenBlank="true" uuid="449e72bd-3d34-49cb-b97b-56a697efa00d">
                                        <printWhenExpression><![CDATA[$F{amount}.compareTo(BigDecimal.ZERO) != 0]]></printWhenExpression>
                                    </reportElement>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="80" uuid="737899e6-300f-4f5c-9540-6f0a651da136">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
                            <jr:detailCell height="50">
                                <textField>
                                    <reportElement x="0" y="0" width="80" height="25" uuid="ff305a7f-cc92-44fd-9129-d34644eb96a9"/>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                                <textField  isBlankWhenNull="true">
                                    <reportElement x="0" y="25" width="80" height="25" isRemoveLineWhenBlank="true" uuid="9fdf1746-150d-476b-a2d8-939be7ce53b8">
                                        <printWhenExpression><![CDATA[$F{amount}.compareTo(BigDecimal.ZERO) != 0]]></printWhenExpression>
                                    </reportElement>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="110" uuid="899fd6fd-070c-4431-9c42-87bc88692519">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
                            <jr:detailCell height="50">
                                <textField>
                                    <reportElement x="0" y="0" width="110" height="25" uuid="c55cb6ab-7141-4b70-946f-1b12964dfd32"/>
                                    <textFieldExpression><![CDATA[$F{amount}]]></textFieldExpression>
                                </textField>
                                <textField isBlankWhenNull="true">
                                    <reportElement x="0" y="25" width="110" height="25" isRemoveLineWhenBlank="true" uuid="2ab0a420-93dc-40ef-a04b-6dc06d0412e0">
                                        <printWhenExpression><![CDATA[$F{amount}.compareTo(BigDecimal.ZERO) != 0]]></printWhenExpression>
                                    </reportElement>
                                    <textFieldExpression><![CDATA[$F{amount}]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="140" uuid="da779d81-2a6a-47de-867f-c1148c5df1b1">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/>
                            <jr:detailCell height="50">
                                <textField>
                                    <reportElement x="0" y="0" width="140" height="25" uuid="ceec9404-d9a8-4fc9-be55-4bf97b417f2d"/>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                                <textField isBlankWhenNull="true">
                                    <reportElement x="0" y="25" width="140" height="25" isRemoveLineWhenBlank="true" uuid="4478d7ca-8c1a-444a-83db-753e8c0963da">
                                        <printWhenExpression><![CDATA[$F{amount}.compareTo(BigDecimal.ZERO) != 0]]></printWhenExpression>
                                    </reportElement>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:column width="140" uuid="81de9dce-8f7b-4c45-a8d9-139824d1fa18">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column6"/>
                            <jr:detailCell height="50">
                                <textField>
                                    <reportElement x="0" y="0" width="140" height="25" uuid="a1be2113-f227-4e3c-890f-6c1613f91abc"/>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                                <textField isBlankWhenNull="true">
                                    <reportElement x="0" y="25" width="140" height="25" isRemoveLineWhenBlank="true" uuid="85ee156e-f003-4b8e-af33-23535dfe4e53">
                                        <printWhenExpression><![CDATA[$F{amount}.compareTo(BigDecimal.ZERO) != 0]]></printWhenExpression>
                                    </reportElement>
                                    <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                    </jr:table>
                </componentElement>

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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