Jump to content
Changes to the Jaspersoft community edition download ×

Avoid blank space on List element


p233029

Recommended Posts

Hi all!

I have a problem with a subreport where I'm using a List element.
The list can be of an empty source or the data inside of it be blank. When this happen, I want it to do not show in my report.

To do this, I'm controlling the "Print when Expression" and setting the "Remove line when blank" variable to true.


The problem is that the list don't show (that's ok) but there is an empty line that make all my report to move... Is there an option to make this blank line to do not show?

Thank you!

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Check this jrxml. there are 2 list datasets. try to remove the first dataset sql and then the 2nd list dataset moves up.

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  --><!-- 2017-04-13T10:20:44 --><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="list" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d9bbb141-8dfb-40aa-b09d-81140ea6a430">    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>    <property name="com.jaspersoft.studio.unit." value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>    <subDataset name="list" uuid="216b8ad6-195c-44d2-96e6-5c750d85f459">        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>        <queryString>            <![CDATA[select 1 as ID from dualunionselect 2 as ID  from dualunionselect 3 as ID from dualunionselect 4 as ID from dual]]>        </queryString>        <field name="ID" class="java.math.BigDecimal"/>        <variable name="Count" class="java.lang.Integer" calculation="Count">            <variableExpression><![CDATA[$F{ID}]]></variableExpression>        </variable>        <variable name="max_count" class="java.lang.Integer" calculation="Highest">            <variableExpression><![CDATA[$V{Count}]]></variableExpression>        </variable>    </subDataset>    <subDataset name="list2" uuid="5c7f6510-f936-4b5e-b024-0a06abe88ef8">        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>        <queryString>            <![CDATA[select 1 as ID from dualunionselect 2 as ID  from dualunionselect 3 as ID from dual]]>        </queryString>        <field name="ID" class="java.math.BigDecimal"/>        <variable name="Count" class="java.lang.Integer" calculation="Count">            <variableExpression><![CDATA[$F{ID}]]></variableExpression>        </variable>        <variable name="max_count" class="java.lang.Integer" calculation="Highest">            <variableExpression><![CDATA[$V{Count}]]></variableExpression>        </variable>    </subDataset>    <queryString>        <![CDATA[select * from dual]]>    </queryString>    <field name="DUMMY" class="java.lang.String"/>    <variable name="Variable_1" class="java.lang.Integer" resetType="None"/>    <variable name="Variable_2" class="java.lang.Integer" resetType="None"/>    <background>        <band splitType="Stretch"/>    </background>    <detail>        <band height="10" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="100" height="10" uuid="44f9fd26-6561-4926-a0af-b4f8f55152dd"/>                <textFieldExpression><![CDATA[$F{DUMMY}]]></textFieldExpression>            </textField>        </band>    </detail>    <summary>        <band height="80" splitType="Stretch">            <componentElement>                <reportElement x="0" y="20" width="200" height="20" isRemoveLineWhenBlank="true" uuid="2ebeeaba-1db8-4106-9444-59a926860a4f">                    <property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>                    <printWhenExpression><![CDATA[($V{Variable_1}!=null ) == false]]></printWhenExpression>                </reportElement>                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">                    <datasetRun subDataset="list" uuid="4dd410cc-f8bf-447a-9014-8643d98c0233">                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>                        <returnValue fromVariable="Count" toVariable="Variable_1"/>                    </datasetRun>                    <jr:listContents height="20" width="200">                        <textField>                            <reportElement x="0" y="0" width="200" height="20" isRemoveLineWhenBlank="true" uuid="fd84641d-4739-4134-b146-b2c664021a6d"/>                            <box>                                <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                                <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                                <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                                <rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                            </box>                            <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>                        </textField>                    </jr:listContents>                </jr:list>            </componentElement>            <componentElement>                <reportElement positionType="Float" x="0" y="60" width="200" height="20" uuid="092491e7-42a8-42e3-b716-92ea289408a3">                    <property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>                </reportElement>                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">                    <datasetRun subDataset="list2" uuid="81d6c38e-0444-449b-bf52-587707d7ae6d">                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>                        <returnValue fromVariable="Count" toVariable="Variable_2"/>                    </datasetRun>                    <jr:listContents height="20" width="200">                        <textField>                            <reportElement x="0" y="0" width="200" height="20" uuid="3f50a0cd-de19-48bd-aa10-dbfd84584703"/>                            <box>                                <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                                <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                                <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                                <rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>                            </box>                            <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>                        </textField>                    </jr:listContents>                </jr:list>            </componentElement>            <textField evaluationTime="Report">                <reportElement positionType="Float" x="0" y="40" width="270" height="20" uuid="8cdc0e35-2df7-4a64-b3ab-cfea726040da"/>                <textElement>                    <font isBold="true"/>                </textElement>                <textFieldExpression><![CDATA["the 2nd list has " + $V{Variable_2} + " rows"]]></textFieldExpression>            </textField>            <textField evaluationTime="Report">                <reportElement x="0" y="0" width="270" height="20" uuid="7d866c3c-1171-4b8f-b447-0a23b7660d01"/>                <textElement>                    <font isBold="true"/>                </textElement>                <textFieldExpression><![CDATA["the 1st list has " + $V{Variable_1} + " rows"]]></textFieldExpression>            </textField>        </band>    </summary></jasperReport>[/code]

I'm creating some variables and passing those variables on to the main report to check whether or not to display the list.

Link to comment
Share on other sites

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