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

Textfield adjust to detail band height


fanethemighty

Recommended Posts

Hi!

I'm trying to create a simple grouping of rows like on the following image:

desired.png.a8ac8feb8306fbcbe5bd6cc19bb19922.png

That is I have a simple bean with fields "group" and "detail"; grouping is done by the "group" field values. In the detail band, I would liked rows grouped by the "group" field and the group valued aligned with middle vertical alignment. For this I have created a simple report using iReport like in the next picture (everything is in the detail band)

source.PNG.bbaae325df57b187acbe89150c863b7e.PNG

I have investigated several possibilities for defining the first textfield, but none of them successful. Here are some options for the textfiled containing $F{Group} and their respective outputs.

A. Print Repeated values=false, Position Type=Fix Relative to Bottom, Stretch Type=Relative to Band Height, Evaluation Time=Band (from docs: BAND The element will be evaluated at band end.BAND)

Result can be seen in the next picture.

groupA.PNG.5ca49557c8b9ff37e87316b631cbd0ed.PNG

B. Print Repeated values=true, Position Type=Fix Relative to Bottom, Stretch Type=Relative to Band Height, Evaluation Time=Band

Result: the same as previous

C. Print Repeated values=true, Position Type=Fix Relative to Bottom, Stretch Type=Relative to Band Height, Evaluation Time=Band, Print When Group Changes=group

Result: the same as previous

D. Print Repeated values=false, Position Type=Fix Relative to Bottom, Stretch Type=Relative to Band Height, Evaluation Time=Now, Print When Group Changes=group

Result: the same as previous

E. Print Repeated values=false, Position Type=Fix Relative to Bottom, Stretch Type=Relative to Band Height, Evaluation Time=Group, Evaluation Group=group, Print When Group Changes=null

Result: the same as previous

F. Print Repeated values=false, Position Type=Fix Relative to Bottom, Stretch Type=Relative to Band Height, Evaluation Time=Group, Evaluation Group=group, Print When Group Changes=group

Result: the same as previous

 

So, as you see, no real luck.

Here is the attached source for the report.

<?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="TestBandHeight" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">	<property name="ireport.zoom" value="1.0"/>	<property name="ireport.x" value="0"/>	<property name="ireport.y" value="0"/>	<queryString>		<![CDATA[]]>	</queryString>	<field name="Group" class="java.lang.String"/>	<field name="Detail" class="java.lang.String"/>	<group name="group">		<groupExpression><![CDATA[$F{Group}]]></groupExpression>	</group>	<detail>		<band height="28" splitType="Stretch">			<textField isStretchWithOverflow="true" evaluationTime="Group" evaluationGroup="group">				<reportElement positionType="FixRelativeToBottom" stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="114" y="0" width="100" height="28" printWhenGroupChanges="group" backcolor="#FFCC00"/>				<textElement textAlignment="Center" verticalAlignment="Middle"/>				<textFieldExpression><![CDATA[$F{Group}]]></textFieldExpression>			</textField>			<textField>				<reportElement mode="Opaque" x="214" y="0" width="100" height="28" backcolor="#00CCCC"/>				<textElement textAlignment="Center" verticalAlignment="Middle"/>				<textFieldExpression><![CDATA[$F{Detail}]]></textFieldExpression>			</textField>		</band>	</detail></jasperReport>[/code]

 

Here is the same question, unfortunately with no response:

http://community.jaspersoft.com/questions/540767/stretching-non-overflowing-text-field-detail-band

Thank you.

 
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

It is not possible to vertical align a text in a text filed over multiple details. For a bunch of good reasons.

What you could do, is group the report by your column a, place a stretching text field. Then you could use a subreport, table or list to show the lines belonging to that group.

Possibly using a crosstab would be a solution, too.

Cheers, Thomas

http://www.thomaszimmer.net

Link to comment
Share on other sites

  • 4 years later...

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