13.07.2015 Views

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>Figure 7-12The new group bands in the design panelWhen you add a group to the document, <strong>iReport</strong> creates an instance of the built-in variable _COUNT for thenew group. In our case, the variable is named First_Letter_COUNT (Figure 7-13). It represents the number of recordsprocessed for the group; if we display this variable in a textfield in the group footer, it will display how many records the groupcontains.Figure 7-13The group in the outline viewNow we can add some content to the group header and footer. In particular, we can add the initial letter to which the grouprefers, and we can add in the footer the First_Letter_COUNT variable. For the letter, just add a Textfield in the group headerand use the same textfield expression as you did for the group. The textfield class can be set to String (because we are usingGroovy or JavaScript). If you use Java, the expression for the textfield should be changed a little bit. Java is a bit more severein terms of type matching, and since the charAt() function returns a char, we can convert this value in a String byconcatenating an empty string. (This is actually a dirty but simple way to cast any Java object in a String without checking ifthe object is null). So the expression in Java should be:“” +$F{LASTNAME}.charAt(0)118

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!