Java Reference
In-Depth Information
After compiling, filling, and exporting the preceding JRXML template, we should get
a report that looks like the following:
As we can see, setting the positionType attribute of <reportElement> to Float
made JasperReports ignore the y position of the <staticText> element, which was
pushed down by the stretched <textField> element.
The third possible value for positionType is FixRelativeToBottom . This value is
similar to FixRelativeToTop , with the only difference being that the element keeps
its position relative to the bottom of the band, as opposed to its top.
It is not only possible to control the position of elements inside a band, when one
of its elements stretches, but also possible to control their size. This is accomplished
by the stretchType attribute of <reportElement> . The following example
demonstrates how we can set a report element to stretch to match the tallest element
in its group:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="RelativeToTallestObjectDemo">
<field name="lots_of_data" class="java.lang.String"/>
<detail>
<band height="50">
<elementGroup>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="100" height="24"/>
<box border="Thin"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{lots_of_data}]]>
</textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="101" y="0" width="150" height="24"/>
<box border="Thin"/>
<textFieldExpression class="java.lang.String">
 
Search WWH ::




Custom Search