Jump to content
Changes to the Jaspersoft community edition download ×

Table with conditional display causes blank space at the bottom of the page, when the condition is not met


diyosifova

Recommended Posts

Hi,

I am using iReport Designer 5.2 and data source connection to a Oracle database. I have a report with 8 tables in Detail band, which are with conditional display. That condition is set in the printWhenExpression attribute. Depend on that condition only one or two tables are printed. Also I set the attribute isRemoveLineWhenBlank="true".
So far so good but I noticed that on the same page there is blank space at the bottom, which causes some of the data printed on a new page, when there is enough space for it in the first page.
Each table is with heigth=20. I noticed that when the table is not to be printed, it's size is cut from the page.

I found a workaround to my problem by setting the height=1 for each table in the report and that way everything is printed on one page as it should be.  

I created two examples and my question is: How can they generate the same result?

First jasper report with no table:

<?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="example" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="af42ab41-2654-42de-92d1-de1d3bfcc542">    <property name="ireport.zoom" value="1.0"/>    <property name="ireport.x" value="0"/>    <property name="ireport.y" value="0"/>    <queryString>        <![CDATA[select listagg(rownum, chr(13)||chr(10)) within group (order by rownum) c1from dualconnect by rownum <= 100union allselect listagg(rownum, chr(13)||chr(10)) within group (order by rownum) c1from dualconnect by rownum <= 100]]>    </queryString>    <field name="C1" class="java.lang.String"/>    <background>        <band splitType="Stretch"/>    </background>    <detail>        <band height="20" splitType="Stretch">            <textField isStretchWithOverflow="true">                <reportElement uuid="3e71dfdd-312f-48c5-8720-0b8268766b1c" positionType="Float" x="0" y="0" width="555" height="20"/>                <textElement/>                <textFieldExpression><![CDATA[$F{C1}]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>[/code]


Second jasper report with table, which should not be printed:

<?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="example" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="af42ab41-2654-42de-92d1-de1d3bfcc542">    <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="Table Dataset 1" uuid="17ce0af8-a3de-46c7-bdce-30b19aed54e8">        <queryString>            <![CDATA[select 1 as c1, 2 as c2, 3 as c3, 4 as c4from dual]]>        </queryString>        <field name="C1" class="java.math.BigDecimal"/>        <field name="C2" class="java.math.BigDecimal"/>        <field name="C3" class="java.math.BigDecimal"/>        <field name="C4" class="java.math.BigDecimal"/>    </subDataset>    <queryString>        <![CDATA[select listagg(rownum, chr(13)||chr(10)) within group (order by rownum) c1from dualconnect by rownum <= 100union allselect listagg(rownum, chr(13)||chr(10)) within group (order by rownum) c1from dualconnect by rownum <= 100]]>    </queryString>    <field name="C1" class="java.lang.String"/>    <background>        <band splitType="Stretch"/>    </background>    <detail>        <band height="110" splitType="Stretch">            <textField isStretchWithOverflow="true">                <reportElement uuid="3e71dfdd-312f-48c5-8720-0b8268766b1c" positionType="Float" x="0" y="90" width="555" height="20"/>                <textElement/>                <textFieldExpression><![CDATA[$F{C1}]]></textFieldExpression>            </textField>            <componentElement>                <reportElement uuid="dd796242-5bd6-4a50-b495-78922b0078b9" key="table" style="table" positionType="Float" x="0" y="0" width="555" height="90" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true">                    <printWhenExpression><![CDATA[$F{C1}.isEmpty()]]></printWhenExpression>                </reportElement>                <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="Table Dataset 1" uuid="d5c30cb9-99cc-4b9b-9c99-0e414ab6377d">                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>                    </datasetRun>                    <jr:column width="90" uuid="a41bd45a-ac8c-445a-8748-2c09f9aabbb5">                        <jr:tableHeader style="table_TH" height="30"/>                        <jr:tableFooter style="table_TH" height="30"/>                        <jr:columnHeader style="table_CH" height="30">                            <staticText>                                <reportElement uuid="55a27c44-3ef3-4076-bd68-2826113efbe7" x="0" y="0" width="90" height="30"/>                                <textElement/>                                <text><![CDATA[C1]]></text>                            </staticText>                        </jr:columnHeader>                        <jr:columnFooter style="table_CH" height="30"/>                        <jr:detailCell style="table_TD" height="20">                            <textField>                                <reportElement uuid="52fb764f-d12c-4447-a576-2c58eceac6a8" x="0" y="0" width="90" height="20"/>                                <textElement/>                                <textFieldExpression><![CDATA[$F{C1}]]></textFieldExpression>                            </textField>                        </jr:detailCell>                    </jr:column>                    <jr:column width="90" uuid="8851bec7-3584-4ca1-a8f3-02cb3cf17046">                        <jr:tableHeader style="table_TH" height="30"/>                        <jr:tableFooter style="table_TH" height="30"/>                        <jr:columnHeader style="table_CH" height="30">                            <staticText>                                <reportElement uuid="58552056-9382-40c7-b1f9-bc724ef30e76" x="0" y="0" width="90" height="30"/>                                <textElement/>                                <text><![CDATA[C2]]></text>                            </staticText>                        </jr:columnHeader>                        <jr:columnFooter style="table_CH" height="30"/>                        <jr:detailCell style="table_TD" height="20">                            <textField>                                <reportElement uuid="19352f2c-d280-4212-9c41-d48ae68d8f18" x="0" y="0" width="90" height="20"/>                                <textElement/>                                <textFieldExpression><![CDATA[$F{C2}]]></textFieldExpression>                            </textField>                        </jr:detailCell>                    </jr:column>                    <jr:column width="90" uuid="113cb369-8bda-49e7-bd63-625b7d3b80f4">                        <jr:tableHeader style="table_TH" height="30"/>                        <jr:tableFooter style="table_TH" height="30"/>                        <jr:columnHeader style="table_CH" height="30">                            <staticText>                                <reportElement uuid="ce981f0c-2ac5-42f6-9ea3-9beac9841778" x="0" y="0" width="90" height="30"/>                                <textElement/>                                <text><![CDATA[C3]]></text>                            </staticText>                        </jr:columnHeader>                        <jr:columnFooter style="table_CH" height="30"/>                        <jr:detailCell style="table_TD" height="20">                            <textField>                                <reportElement uuid="973ce891-454d-4afd-835f-e28e9015c263" x="0" y="0" width="90" height="20"/>                                <textElement/>                                <textFieldExpression><![CDATA[$F{C3}]]></textFieldExpression>                            </textField>                        </jr:detailCell>                    </jr:column>                    <jr:column width="90" uuid="83823efc-4c66-43a3-aea0-8e74e8ce2017">                        <jr:tableHeader style="table_TH" height="30"/>                        <jr:tableFooter style="table_TH" height="30"/>                        <jr:columnHeader style="table_CH" height="30">                            <staticText>                                <reportElement uuid="1023c6a0-dbbe-4324-a445-16c05ac53e05" x="0" y="0" width="90" height="30"/>                                <textElement/>                                <text><![CDATA[C4]]></text>                            </staticText>                        </jr:columnHeader>                        <jr:columnFooter style="table_CH" height="30"/>                        <jr:detailCell style="table_TD" height="20">                            <textField>                                <reportElement uuid="5b74e899-3d6d-40b8-bf93-cd426e0cc369" x="0" y="0" width="90" height="20"/>                                <textElement/>                                <textFieldExpression><![CDATA[$F{C4}]]></textFieldExpression>                            </textField>                        </jr:detailCell>                    </jr:column>                </jr:table>            </componentElement>        </band>    </detail></jasperReport>[/code]


With subreports is the same. Is there a property I am missing?

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