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

TextFields not streching under Group Header


kumarjasper

Recommended Posts

Hi,

I am calling subreport from group header. I have text field in subreport. The text field in subreport doesn't strech when the content overflows the height of Textfield.

 

Here is the scenario:

 

The group definition is

 

<group name="Group_1">

<groupExpression><![CDATA[null]]></groupExpression>

<groupHeader>

<band height="85">

<subreport>

<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="3" y="43" width="566" height="40" isRemoveLineWhenBlank="true">

<printWhenExpression><![CDATA[new Boolean($F{clinicalHistory}.size() > 0)]]></printWhenExpression>

</reportElement>

<dataSourceExpression><![CDATA[new JRBeanCollectionDataSource((Collection) $F{clinicalHistory})]]></dataSourceExpression>

<subreportExpression class="java.lang.String"><![CDATA[$P{TEMPLATE_DIR}+"ClinicalInfo.jasper"]]></subreportExpression>

</subreport>

<subreport>

<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="3" y="2" width="566" height="40" isRemoveLineWhenBlank="true">

<printWhenExpression><![CDATA[new Boolean($F{amendments}.size() > 0)]]></printWhenExpression>

</reportElement>

<dataSourceExpression><![CDATA[new JRBeanCollectionDataSource((Collection) $F{amendments})]]></dataSourceExpression>

<subreportExpression class="java.lang.String"><![CDATA[$P{TEMPLATE_DIR}+"Amendments.jasper"]]></subreportExpression>

</subreport>

</band>

</groupHeader>

<groupFooter>

<band/>

</groupFooter>

</group>

 

 

SUBREPORT'S DETAIL SECTION IS:

 

<detail>

<band height="15" isSplitAllowed="true">

<textField isStretchWithOverflow="true" isBlankWhenNull="true">

<reportElement key="textField" style="Text" positionType="Float" x="1" y="0" width="560" height="15" isRemoveLineWhenBlank="true" stretchType="RelativeToTallestObject" isPrintWhenDetailOverflows="true">

<printWhenExpression><![CDATA[new Boolean($F{content} != null)]]></printWhenExpression>

</reportElement>

<textElement isStyledText="true"/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{content}.toString()]]></textFieldExpression>

</textField>

</band>

</detail>

 

Please let me know if anybody knows the solution

 

Thanks

Kumar

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Don't use the "RelativeToTallestObject" attribute for your SubReportElement! This attribute is (in most cases) just useful for stretching rectangles/vertical lines etc.... but as the TextField is stretching itself, it needn't stretch to the Tallest Object.

 

As I also use SubReports with stretching fields (over several pages even) I don't have Problems. So it must work.

 

Additionally I would create a second group for your second subreport, and put this subreport in its own band (I expierenced some troubles when many subreports are located in the same band)

 

hth

C-Box

Link to comment
Share on other sites

Streching works excellent in detail section but it doesn't work in groupHeader.

 

i tried my application by placing two subreports in a seperate bands instead of same band. but still doesn't work. Is there anything which i am missing in the above posted XML.

 

let me know if anyone knows the solution.

 

Thanks

Kumar

Link to comment
Share on other sites

Hmm stretching works quite well in GroupHeader/FooterBands.... so look at this small sample (works without data... just change the parameter default-value with more strings to see how fine stretching works. :-)

 

[code:1]<?xml version="1.0" encoding="UTF-8" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="Bericht1"

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="595"

pageHeight="842"

columnWidth="535"

columnSpacing="0"

leftMargin="30"

rightMargin="30"

topMargin="20"

bottomMargin="20"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<property name="ireport.scriptlethandling" value="0" />

<property name="ireport.encoding" value="UTF-8" />

<import value="java.util.*" />

<import value="net.sf.jasperreports.engine.*" />

<import value="net.sf.jasperreports.engine.data.*" />

 

<parameter name="test" isForPrompting="true" class="java.lang.Integer">

<defaultValueExpression ><![CDATA[new Integer(1)]]></defaultValueExpression>

</parameter>

<parameter name="teststring" isForPrompting="false" class="java.lang.String">

<parameterDescription><![CDATA[just a long long text]]></parameterDescription>

<defaultValueExpression ><![CDATA["fhdsfhsdjfhsddjfhsdjfhsjkfhsjkhfjkshfkjshfjksfhsjkfhsjfhsjhfjsfhsjhfsjhfsjhfsjfhsjfhsjfhsjfhsjfhsjfhsjfsjfhsjfhsjfhsjfsjhfsjfsjfsjfsjfhsjfhsjfhsjfhsjfhsjfhjsfhsjfhsjfh"]]></defaultValueExpression>

</parameter>

 

 

<group name="g1" >

<groupExpression><![CDATA[]]></groupExpression>

<groupHeader>

<band height="19" isSplitAllowed="true" >

<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="127"

y="6"

width="100"

height="13"

key="textField"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$P{teststring}]]></textFieldExpression>

</textField>

<staticText>

<reportElement

x="5"

y="6"

width="117"

height="13"

key="staticText-1"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<text><![CDATA[Test-String Parameter:]]></text>

</staticText>

</band>

</groupHeader>

<groupFooter>

<band height="0" isSplitAllowed="true" >

</band>

</groupFooter>

</group>

<background>

<band height="0" isSplitAllowed="true" >

</band>

</background>

<title>

<band height="50" isSplitAllowed="true" >

<staticText>

<reportElement

x="0"

y="12"

width="535"

height="26"

key="staticText-2"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement textAlignment="Center">

<font pdfFontName="Helvetica-BoldOblique" size="16" isBold="true" isItalic="true" isUnderline="true"/>

</textElement>

<text><![CDATA[C-Box small TestReport for some Trial-And-Errors]]></text>

</staticText>

</band>

</title>

<pageHeader>

<band height="0" isSplitAllowed="true" >

</band>

</pageHeader>

<columnHeader>

<band height="0" isSplitAllowed="true" >

</band>

</columnHeader>

<detail>

<band height="26" isSplitAllowed="true" >

<textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="175"

y="13"

width="66"

height="13"

key="textField-1"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[new DecimalFormat("0000000000"«»).format($P{test})]]></textFieldExpression>

</textField>

<staticText>

<reportElement

x="5"

y="13"

width="165"

height="13"

key="staticText-3"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<text><![CDATA[Test Integer with leading Zeros:]]></text>

</staticText>

</band>

</detail>

<columnFooter>

<band height="0" isSplitAllowed="true" >

</band>

</columnFooter>

<pageFooter>

<band height="22" isSplitAllowed="true" >

<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="330"

y="4"

width="100"

height="18"

key="textField"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement textAlignment="Right">

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA["Seite " + $V{PAGE_NUMBER} + " von "]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="430"

y="4"

width="100"

height="18"

key="textField"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER} + ""]]></textFieldExpression>

</textField>

</band>

</pageFooter>

<summary>

<band height="0" isSplitAllowed="true" >

</band>

</summary>

</jasperReport>

[/code:1]

 

are you SURE that you have set all StretchTypes from "RelativeToTallestObject" to "[color=#FF0000]NoStretch[/color]"

!??!?

 

hth

C-Box

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