Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove line when blank when beside an image

So I figured out how to have a textbox be removed and it's space collapse when it is null/blank.

But now I have an image on the other side of the page that is stopping this functionality.

I'm guessing since it is on the same line it won't collapse the space.

This is what it looks like:

...                                                     -------------------
Address 1                                              |                   |  
Address 2 (if blank remove)                            |       PICTURE     |
Address 3 (if blank remove)                            |                   |
...                                                     -------------------

Is there a way to have the image not affect this? Can I put it in a frame or something? Or is there a property I am unaware of?

Hopefully someone has come across this before.

like image 728
Delphy Avatar asked Oct 01 '14 14:10

Delphy


Video Answer


1 Answers

Since you have figured out "how to have a textbox be removed and it's space collapse when it is null/blank", I assume that you are aware of attributes like isBlankWhenNull="true" and isRemoveLineWhenBlank="true".

But now you have a picture in the same vertical space along with address fields. So you have to put them into two different vertical frames. Enclose the fields Address1, Address2, Address3 etc. into one frame and picture into other frame. Here is the sample JRXML code to test it. Save this code as report2.jrxml and run it. Play around the values of parm1...parm5 to get desired output.

<?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="report2" language="groovy" pageWidth="979" pageHeight="693" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="979" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a6ccd207-3a74-42e6-8486-fc3b01795fb5">
    <parameter name="par1" class="java.lang.String">
        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>
    </parameter>
    <parameter name="par2" class="java.lang.String">
        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>
    </parameter>
    <parameter name="par3" class="java.lang.String">
        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>
    </parameter>
    <parameter name="par4" class="java.lang.String">
        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>
    </parameter>
    <parameter name="par5" class="java.lang.String">
        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>
    </parameter>
    <pageHeader>
        <band height="174" splitType="Stretch">
            <line>
                <reportElement x="10" y="61" width="520" height="1" uuid="9e329029-596a-4741-80b2-4dd31e7f0a2a"/>
            </line>
            <line>
                <reportElement x="10" y="157" width="520" height="1" uuid="eee16285-f6e5-4275-9911-b8ba0b330c08"/>
            </line>
            <frame>
                <reportElement x="46" y="65" width="154" height="76" uuid="fac4c0b1-a3b2-431a-b766-1954512e5b12"/>
                <textField isBlankWhenNull="true">
                    <reportElement x="42" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="949799db-d6be-404d-98c5-e6a69c0d917f"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textFieldExpression><![CDATA[$P{par3} == null ? null : "P3: " + $P{par3}]]></textFieldExpression>
                </textField>
                <textField isBlankWhenNull="true">
                    <reportElement x="42" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="a1b3fa51-8c0e-496d-8759-2a51eb58bc33"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textFieldExpression><![CDATA[$P{par1} == null ? null : "P1: " + $P{par1}]]></textFieldExpression>
                </textField>
                <textField isBlankWhenNull="true">
                    <reportElement x="42" y="40" width="52" height="20" isRemoveLineWhenBlank="true" uuid="3944fa92-8b0c-4965-81c2-036696bb1295"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textFieldExpression><![CDATA[$P{par5} == null ? null : "P5: " + $P{par5}]]></textFieldExpression>
                </textField>
            </frame>
            <frame>
                <reportElement x="341" y="65" width="189" height="76" uuid="b074b915-2d61-4df8-95b1-12e3901b0604"/>
                <textField isBlankWhenNull="true">
                    <reportElement x="62" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="8c371d13-9eb4-4cf6-b9b8-38052e0dc933"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textFieldExpression><![CDATA[$P{par2} == null ? null : "P2: " + $P{par2}]]></textFieldExpression>
                </textField>
                <textField isBlankWhenNull="true">
                    <reportElement x="62" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="eee7c8ca-a46c-40f1-9701-36a388357108"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textFieldExpression><![CDATA[$P{par4} == null ? null : "P4: " + $P{par4}]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </pageHeader>
</jasperReport>

OUTPUT: When all params are non null When all params are non null

OUTPUT: When P3 is null When P3 is null

like image 81
keenUser Avatar answered Oct 31 '22 19:10

keenUser