user1260928
user1260928

Reputation: 3429

iReport : insert detail band into height fixed frame

I need to display a list in a report.
I need this list to be displayed in a 4cm height frame. If the list is bigger than 4cm, it has to be truncated at 4cm.

I don't know how to do that, how to include a detail band into a height fixed frame.

Upvotes: 1

Views: 1337

Answers (1)

Petter Friberg
Petter Friberg

Reputation: 21710

"how to include a detail band into a height fixed frame?, truncated at 4cm."

The main strength of jasper report is to expand bands to include all the content you provide..

This is why I suggest that you re-think your report, not trying to truncate content but providing less content. The fastest one would be limit the rows displayed in your detail band. es.

<detail>
    <band height="35" splitType="Stretch">
        <printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}<=4)]]></printWhenExpression>
        .... your textField's ...
    </band>
</detail>

even if my datasource provide 100 records I will only print the 4 first one's.

No ugly truncation, instead we handle this case with some logic and one day we can even transform the 4 into a parameter (and as example the user can define how many records he like) or a variable that on the basis of other content defines the number of rows we like to display...

EDIT: Added how to achieve this result with the jr:list component (no detail band)

If you are using a jr:list component (you have no detail band), you need to set the printWhenExpression and isRemoveLineWhenBlank="true" on the components that are inside the jr:list es.

<jr:listContents height="20" width="100">
   <textField>
    <reportElement x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="c65e627e-be7f-4bce-9976-f89c5ccc5d68">
    <printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}<=4)]]></printWhenExpression>
    </reportElement>
    <textFieldExpression><![CDATA[$F{theField}]]></textFieldExpression>
  </textField>
</jr:listContents>

NOTE: new Boolean() is used to be compatible with jasper report v3 (with version 5/6 this is not needed)

Upvotes: 2

Related Questions