Java – stretch a textfield with subreport in the band

ireportjasper-reportsjava

I have a textfield and a subreport in detail band. I pass the value to the subreport which displays details for the particular record. The problem is the textfield doesn't stretch when the subreport displays some value.

Here is a part of my jrxml with detail band:

<detail>
  <band height="40"  isSplitAllowed="true" >
    <textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
      <reportElement
        style="columnHeader"
        mode="Opaque"
        x="0"
        y="0"
        width="108"
        height="20"
        backcolor="#9999FF"
        key="groupMenu-1"/>
      <box></box>
      <textElement textAlignment="Center" verticalAlignment="Middle">
        <font pdfFontName="Helvetica-Bold" isBold="true" isPdfEmbedded ="false" pdfEncoding ="Cp1252"/>
      </textElement>
      <textFieldExpression   class="java.lang.String"><![CDATA[str("Code")]]></textFieldExpression>
    </textField>
    <subreport  isUsingCache="true">
      <reportElement
        mode="Transparent"
        x="0"
        y="39"
        width="100"
        height="1"
        key="subreport-1"
        stretchType="RelativeToTallestObject"
        positionType="Float"
        isPrintWhenDetailOverflows="true"/>
      <subreportParameter  name="requestListId">
        <subreportParameterExpression><![CDATA[$F{SPREADSHEET_REPORT_ID}]]></subreportParameterExpression>
      </subreportParameter>
      <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
      <subreportExpression  class="java.lang.String"><![CDATA[$P{subReportPath}]]></subreportExpression>
    </subreport>
  </band>
</detail>

Best Answer

I'm not sure if this is possible, the textfield when stretching does not push the subreport. But you can handle that in other methods.

  • Why not make a group band over the "Detail" band and set this group expression to $F{CODE} so the group will be rendered each time the code changes and at the same time the Detail band related to this code will be rendered directly after it

  • Second option, why not to send the CODE as a parameter to the subreport and put it in the report header?