3

I have two problems with my Crosstab component.

  1. In my Crosstab I have total row at the beginning of tab and I want to display value from my field in each column. So I created field and put it in total cell. While compiling I've got error "field not found" but when I put this field into details band it is displaying correctly.
  2. Other case. Can I add several total row to my Cross tab and display there values from my Fields?
Alex K
  • 22,315
  • 19
  • 108
  • 236
Tomasz Iwaszko
  • 187
  • 3
  • 14

1 Answers1

4

To display the value in cross tab you need to create a measure

Example

<measure name="myField" class="java.lang.String">
    <measureExpression><![CDATA[$F{myField}]]></measureExpression>
</measure>

Note: the measure can be a simple representation of a field (as in example), with calculation="Nothing" (default value if not indicated), remember to set correct class (same as field)

Now you can add the measure $V{myField} to your crosstab cell:

<textField>
   <reportElement style="Crosstab Data Text" x="0" y="12" width="50" height="12" uuid="2a004def-c91d-40be-ba2a-fac8763fca7b"/>
   <textElement verticalAlignment="Middle">
      <font size="8"/>
      <paragraph lineSpacing="Single"/>
   </textElement>
    <textFieldExpression><![CDATA[$V{myField}]]></textFieldExpression>
</textField>

As for you second question "Can I add several total row to my Cross tab"?, this is a bit unclear, you will get a total row as indicated by the totalPosition attribute on the rowGroup/columnGroup and you can add as many group's as you like.

"Start" - totals are to be positioned before the other buckets.

"End" - totals are to be positioned at the end of the other buckets.

"None" - total are not required for this bucket.

Comment of OP: To solve second problem I just created general rows in Column Header band. – Tomasz Iwaszko

Community
  • 1
  • 1
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109