Jump to content
Changes to the Jaspersoft community edition download ×

how to keep the static field and text field together


patchy_9

Recommended Posts

I tried to create a simple report that has a detail band split type: immediate but I would like to keep the static field and text field to stay together, not split up in different pages.

Please give me any advice.

index(32).png.e397327bf289276a9a7790971f2f583c.png

index(33).png.f56cf3e5d61e71535f15c974a7d49d8d.png

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.2.0  --><!-- 2016-12-27T13:41:45 --><jasperReportxmlns="http://jasperreports.sourceforge.net/jasperreports"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreportshttp://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Tree"pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20"rightMargin="20" topMargin="20" bottomMargin="20"uuid="2f6e4db4-9f8f-4ffe-9759-6e1fd142f492"><property name="template.type" value="columnar"/><property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter (5)"/><style name="Title" forecolor="#000000" fontName="Times New Roman" fontSize="50" isBold="false"/><style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18" isBold="false"/><style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/><style name="Detail" mode="Transparent" fontName="Times New Roman"/><style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">  <conditionalStyle>   <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>   <style mode="Opaque" backcolor="#F0EFEF"/>  </conditionalStyle></style><queryString language="json">  <![CDATA[user]]></queryString><field name="id" class="java.lang.String">  <fieldDescription><![CDATA[id]]></fieldDescription></field><field name="first" class="java.lang.String">  <fieldDescription><![CDATA[first]]></fieldDescription></field><field name="last" class="java.lang.String">  <fieldDescription><![CDATA[last]]></fieldDescription></field><field name="addressLine1" class="java.lang.String">  <fieldDescription><![CDATA[addresses.addressLine1]]></fieldDescription></field><field name="addressLine2" class="java.lang.String">  <fieldDescription><![CDATA[addresses.addressLine2]]></fieldDescription></field><field name="addressLine3" class="java.lang.String">  <fieldDescription><![CDATA[addresses.addressLine3]]></fieldDescription></field><field name="city" class="java.lang.String">  <fieldDescription><![CDATA[addresses.city]]></fieldDescription></field><field name="state" class="java.lang.String">  <fieldDescription><![CDATA[addresses.state]]></fieldDescription></field><field name="zip" class="java.lang.String">  <fieldDescription><![CDATA[addresses.zip]]></fieldDescription></field><field name="phone1" class="java.lang.String">  <fieldDescription><![CDATA[phone.telephone1]]></fieldDescription></field><field name="phone2" class="java.lang.String">  <fieldDescription><![CDATA[phone.telephone2]]></fieldDescription></field><field name="phone3" class="java.lang.String">  <fieldDescription><![CDATA[phone.telephone3]]></fieldDescription></field><background>  <band splitType="Stretch"/></background><pageHeader>  <band height="29">   <staticText>    <reportElement style="SubTitle" x="0" y="0" width="217" height="29" uuid="211c20f3-3a99-4086-9622-1f187165354d"/>    <textElement>     <font size="22" isBold="false"/>    </textElement>    <text><![CDATA[user List]]></text>   </staticText>  </band></pageHeader><detail>  <band height="169" splitType="Immediate">   <staticText>  <reportElement style="Column header" positionType="Float" x="0"y="0" width="20" height="20" forecolor="#000000"uuid="d93c3bbe-31e1-4847-bf94-12d6811c5cd5"/>    <textElement textAlignment="Left">     <font isBold="false"/>    </textElement>    <text><![CDATA[id]]></text>   </staticText>   <textField isStretchWithOverflow="true" isBlankWhenNull="true">  <reportElement style="Detail" positionType="Float" x="20" y="1"width="338" height="18" uuid="96575b26-9b88-49d3-9562-0b4461d15b0e"/>    <textElement>     <font size="14" isBold="true"/>    </textElement>    <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>   </textField>   <staticText>  <reportElement style="Column header" positionType="Float" x="0"y="20" width="132" height="20" forecolor="#000000"uuid="36b072fa-c65b-4551-b905-a1d792131d86"/>    <textElement textAlignment="Left">     <font isBold="false"/>    </textElement>    <text><![CDATA[first]]></text>   </staticText>   <textField isStretchWithOverflow="true" isBlankWhenNull="true">  <reportElement style="Detail" positionType="Float" x="0" y="41"width="132" height="18" uuid="55399657-e580-4058-91d1-76ce00e9baee"/>    <textElement>     <font size="14" isBold="true"/>    </textElement>    <textFieldExpression><![CDATA[$F{first}]]></textFieldExpression>   </textField>   <staticText>  <reportElement style="Column header" positionType="Float" x="132"y="20" width="338" height="20" forecolor="#000000"uuid="8433d652-9225-4a48-9136-45753d7c107e"/>    <textElement textAlignment="Left">     <font isBold="false"/>    </textElement>    <text><![CDATA[last]]></text>   </staticText>   <textField isStretchWithOverflow="true" isBlankWhenNull="true">  <reportElement style="Detail" positionType="Float" x="132" y="41"width="338" height="18" uuid="bd64961f-95da-4e43-b807-11fce0d232a2"/>    <textElement>     <font size="14" isBold="true"/>    </textElement>    <textFieldExpression><![CDATA[$F{last}]]></textFieldExpression>   </textField>   <staticText>  <reportElement style="Column header" positionType="Float" x="20"y="65" width="535" height="20" forecolor="#000000"uuid="f46560e8-4ef1-4695-817e-e1c51277d31f"/>    <textElement textAlignment="Left">     <font isBold="false"/>    </textElement>    <text><![CDATA[addresses]]></text>   </staticText>   <textField isStretchWithOverflow="true" isBlankWhenNull="true">  <reportElement style="Detail" positionType="Float" x="20" y="85"width="535" height="18" uuid="8048e91b-9cd2-4c35-b9da-d183f44f845d"/>    <textElement>     <font size="14" isBold="true"/>    </textElement>    <textFieldExpression><![CDATA[$F{addressLine1}+ "rn" +  (($F{addressLine2} == null || $F{addressLine2}.equals("")) ? "" :( $F{addressLine2} + "rn")) +       (($F{addressLine3} == null || $F{addressLine3}.equals("") ) ? "" :( $F{addressLine3} + "rn")) +       $F{city}+", "+$F{state}+" "+$F{zip}]]></textFieldExpression>   </textField>   <staticText>  <reportElement style="Column header" positionType="Float" x="20"y="110" width="132" height="20" forecolor="#000000"uuid="14e5e496-3014-41a3-94c3-c31f993db507"/>    <textElement textAlignment="Left">     <font isBold="false"/>    </textElement>    <text><![CDATA[home phone]]></text>   </staticText>   <textField isStretchWithOverflow="true" isBlankWhenNull="true">  <reportElement style="Detail" positionType="Float" x="20" y="130"width="132" height="18" uuid="10bbe501-d6d9-43c5-a36f-b9d325c296e7"/>    <textElement>     <font size="14" isBold="true"/>    </textElement>    <textFieldExpression><![CDATA[$F{phone1}]]></textFieldExpression>   </textField>   <textField isStretchWithOverflow="true" isBlankWhenNull="true">  <reportElement style="Detail" positionType="Float" x="180" y="130"width="132" height="18" uuid="10e21574-b124-457d-ac44-573b61a5c9da"/>    <textElement>     <font size="14" isBold="true"/>    </textElement>    <textFieldExpression><![CDATA[$F{phone2}]]></textFieldExpression>   </textField>   <staticText>  <reportElement style="Column header" positionType="Float" x="180"y="110" width="132" height="20" forecolor="#000000"uuid="671c9259-2bd9-478e-b1f8-f7649cfdf9c6"/>    <textElement textAlignment="Left">     <font isBold="false"/>    </textElement>    <text><![CDATA[work phone]]></text>   </staticText>   <textField isStretchWithOverflow="true" isBlankWhenNull="true">  <reportElement style="Detail" positionType="Float" x="330" y="130"width="132" height="18" uuid="f951bc49-2afe-4e0a-80ec-cde69757d5cc"/>    <textElement>     <font size="14" isBold="true"/>    </textElement>    <textFieldExpression><![CDATA[$F{phone3}]]></textFieldExpression>   </textField>   <staticText>  <reportElement style="Column header" positionType="Float" x="330"y="110" width="132" height="20" forecolor="#000000"uuid="abce1b54-5068-476e-96cc-83f4f81e33c9"/>    <textElement textAlignment="Left">     <font isBold="false"/>    </textElement>    <text><![CDATA[mobile phone]]></text>   </staticText>  </band></detail><pageFooter>  <band height="13" splitType="Stretch">   <frame>  <reportElement mode="Opaque" x="2" y="0" width="555" height="13"forecolor="#D0B48E" backcolor="#9DB1B8"uuid="bfdca178-800d-445c-9a31-bb616a00e8ce"/>    <textField evaluationTime="Report">   <reportElement style="Column header" x="513" y="0" width="40"height="13" forecolor="#FFFFFF"uuid="2fba0f87-635e-476d-858f-d102b26146fe"/>     <textElement verticalAlignment="Middle">      <font size="10" isBold="false"/>     </textElement>     <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>    </textField>    <textField>   <reportElement style="Column header" mode="Transparent" x="433"y="0" width="80" height="13" forecolor="#FFFFFF"uuid="e454d23d-bcfc-4c79-a399-0ef520a3150a"/>     <textElement textAlignment="Right" verticalAlignment="Middle">      <font size="10" isBold="false"/>     </textElement>     <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>    </textField>    <textField pattern="EEEEE dd MMMMM yyyy">   <reportElement style="Column header" x="2" y="0" width="197"height="13" forecolor="#FFFFFF"uuid="14d8de1e-8695-4078-a67f-0e69172574d5"/>     <textElement verticalAlignment="Middle">      <font size="10" isBold="false"/>     </textElement>     <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>    </textField>   </frame>  </band></pageFooter><summary>  <band splitType="Stretch"/></summary></jasperReport>[/code]
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Did you just try increasing the height of the static text so it'll include the fields and ordering the fields to be over the static text.

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0  -->
<!-- 2016-12-28T10:06:13 -->
<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="Tree" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2f6e4db4-9f8f-4ffe-9759-6e1fd142f492">
<property name="template.type" value="columnar"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter (5)"/>
<style name="Title" forecolor="#000000" fontName="Times New Roman" fontSize="50" isBold="false"/>
<style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18" isBold="false"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#F0EFEF"/>
</conditionalStyle>
</style>
<queryString language="json">
<![CDATA[user]]>
</queryString>
<field name="id" class="java.lang.String">
<fieldDescription><![CDATA[id]]></fieldDescription>
</field>
<field name="first" class="java.lang.String">
<fieldDescription><![CDATA[first]]></fieldDescription>
</field>
<field name="last" class="java.lang.String">
<fieldDescription><![CDATA[last]]></fieldDescription>
</field>
<field name="addressLine1" class="java.lang.String">
<fieldDescription><![CDATA[addresses.addressLine1]]></fieldDescription>
</field>
<field name="addressLine2" class="java.lang.String">
<fieldDescription><![CDATA[addresses.addressLine2]]></fieldDescription>
</field>
<field name="addressLine3" class="java.lang.String">
<fieldDescription><![CDATA[addresses.addressLine3]]></fieldDescription>
</field>
<field name="city" class="java.lang.String">
<fieldDescription><![CDATA[addresses.city]]></fieldDescription>
</field>
<field name="state" class="java.lang.String">
<fieldDescription><![CDATA[addresses.state]]></fieldDescription>
</field>
<field name="zip" class="java.lang.String">
<fieldDescription><![CDATA[addresses.zip]]></fieldDescription>
</field>
<field name="phone1" class="java.lang.String">
<fieldDescription><![CDATA[phone.telephone1]]></fieldDescription>
</field>
<field name="phone2" class="java.lang.String">
<fieldDescription><![CDATA[phone.telephone2]]></fieldDescription>
</field>
<field name="phone3" class="java.lang.String">
<fieldDescription><![CDATA[phone.telephone3]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="29">
<staticText>
<reportElement style="SubTitle" x="0" y="0" width="217" height="29" uuid="211c20f3-3a99-4086-9622-1f187165354d"/>
<textElement>
<font size="22" isBold="false"/>
</textElement>
<text><![CDATA[user List]]></text>
</staticText>
</band>
</pageHeader>
<detail>
<band height="169" splitType="Immediate">
<staticText>
<reportElement style="Column header" positionType="Float" x="0" y="0" width="20" height="20" forecolor="#000000" uuid="d93c3bbe-31e1-4847-bf94-12d6811c5cd5"/>
<textElement textAlignment="Left">
<font isBold="false"/>
</textElement>
<text><![CDATA[id]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="20" y="1" width="338" height="18" uuid="96575b26-9b88-49d3-9562-0b4461d15b0e"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="Column header" positionType="Float" x="0" y="20" width="132" height="20" forecolor="#000000" uuid="36b072fa-c65b-4551-b905-a1d792131d86"/>
<textElement textAlignment="Left">
<font isBold="false"/>
</textElement>
<text><![CDATA[first]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="0" y="41" width="132" height="18" uuid="55399657-e580-4058-91d1-76ce00e9baee"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{first}]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="Column header" positionType="Float" x="132" y="20" width="338" height="20" forecolor="#000000" uuid="8433d652-9225-4a48-9136-45753d7c107e"/>
<textElement textAlignment="Left">
<font isBold="false"/>
</textElement>
<text><![CDATA[last]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="132" y="41" width="338" height="18" uuid="bd64961f-95da-4e43-b807-11fce0d232a2"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{last}]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="Column header" positionType="Float" x="20" y="65" width="535" height="20" forecolor="#000000" uuid="f46560e8-4ef1-4695-817e-e1c51277d31f"/>
<textElement textAlignment="Left">
<font isBold="false"/>
</textElement>
<text><![CDATA[addresses]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="20" y="85" width="535" height="18" uuid="8048e91b-9cd2-4c35-b9da-d183f44f845d"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{addressLine1}+ "rn" +
  (($F{addressLine2} == null || $F{addressLine2}.equals("")) ? "" :( $F{addressLine2} + "rn")) +
       (($F{addressLine3} == null || $F{addressLine3}.equals("") ) ? "" :( $F{addressLine3} + "rn")) +
       $F{city}+", "+$F{state}+" "+$F{zip}]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="Column header" positionType="Float" x="20" y="110" width="132" height="38" forecolor="#000000" uuid="14e5e496-3014-41a3-94c3-c31f993db507"/>
<textElement textAlignment="Left">
<font isBold="false"/>
</textElement>
<text><![CDATA[home phone]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="180" y="110" width="132" height="38" forecolor="#000000" uuid="671c9259-2bd9-478e-b1f8-f7649cfdf9c6"/>
<textElement textAlignment="Left">
<font isBold="false"/>
</textElement>
<text><![CDATA[work phone]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="330" y="110" width="132" height="38" forecolor="#000000" uuid="abce1b54-5068-476e-96cc-83f4f81e33c9"/>
<textElement textAlignment="Left">
<font isBold="false"/>
</textElement>
<text><![CDATA[mobile phone]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="330" y="130" width="132" height="18" uuid="f951bc49-2afe-4e0a-80ec-cde69757d5cc"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{phone3}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="180" y="130" width="132" height="18" uuid="10e21574-b124-457d-ac44-573b61a5c9da"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{phone2}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="20" y="130" width="132" height="18" uuid="10bbe501-d6d9-43c5-a36f-b9d325c296e7"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{phone1}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="13" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="2" y="0" width="555" height="13" forecolor="#D0B48E" backcolor="#9DB1B8" uuid="bfdca178-800d-445c-9a31-bb616a00e8ce"/>
<textField evaluationTime="Report">
<reportElement style="Column header" x="513" y="0" width="40" height="13" forecolor="#FFFFFF" uuid="2fba0f87-635e-476d-858f-d102b26146fe"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Column header" mode="Transparent" x="433" y="0" width="80" height="13" forecolor="#FFFFFF" uuid="e454d23d-bcfc-4c79-a399-0ef520a3150a"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement style="Column header" x="2" y="0" width="197" height="13" forecolor="#FFFFFF" uuid="14d8de1e-8695-4078-a67f-0e69172574d5"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</frame>
</band>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
 
Link to comment
Share on other sites

      Thank you so much for your response.

       I tried all the solutions that you gave me but I still have some issues as details below.

        1. using html markup text fields, the issue still exists.

             <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement style="Detail" positionType="Float" x="0" y="99" width="132" height="18" uuid="03227eb0-268e-4f89-8cec-d3a5ec34387f"/>
                <textElement markup="html">
                    <font size="14" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["home phone<br>"+$F{phone1}]]></textFieldExpression>
            </textField>

 

    2. using a frame, it fixed the issue but  when text field is overflow the text field itselt is split up.

<frame>
                <reportElement positionType="Float" x="0" y="60" width="551" height="51" uuid="1b0ed0d0-00ab-4545-a265-5359310553a3"/>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement style="Detail" positionType="Float" x="2" y="30" width="535" height="18" uuid="de745165-d51d-4c3e-b452-9d2dd29a7910"/>
                    <textElement>
                        <font size="14" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{addressLine1}+ "rn" +
  (($F{addressLine2} == null || $F{addressLine2}.equals("")) ? "" :( $F{addressLine2} + "rn")) +
       (($F{addressLine3} == null || $F{addressLine3}.equals("") ) ? "" :( $F{addressLine3} + "rn")) +
       $F{city}+", "+$F{state}+" "+$F{zip}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement style="Column header" positionType="Float" x="2" y="10" width="535" height="38" forecolor="#000000" uuid="692020aa-377a-4e24-9e8a-6fe2f5e4c256"/>
                    <textElement textAlignment="Left">
                        <font isBold="false"/>
                    </textElement>
                    <text><![CDATA[addresses]]></text>
                </staticText>
            </frame>

 

    3. increasing the height of the static text to include the fields -  it is an easy fix solution and it works but when text field is overflow the text field itselt is split up (the same issue as adding a frame). Any suggestions to fix this issue.

 

 

 

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