Pentaho 5.0 Reporting by Example
上QQ阅读APP看书,第一时间看更新

Time for action – adding functions

We will add a function to color the rows in an alternating manner, differentiating between the even and odd rows, just as they appear in the finished report.

  1. In the Data tab, we right-click on Functions, and in the drop-down menu, we select the Add Functions... option.
  2. Now we will see the following window:
  3. This window contains all of the functions that we can create in PRD grouped into categories. In this case, we choose the Row Banding function in the Report category and click on OK to create it:
  4. Next, we configure its name, background color, and the name of the element/object that the function will be applied to:
    • Function Name = RowBanding
    • Active Banding Color = #ccff66
    • Apply Element(s) Named = oddEvenRowBanding
    • Now that the function has been defined, we can apply it
  5. In the Structure tab, navigate to Master Report | Group | Details Body | Details:
  6. In this tab, we configure the following:
    • Attributes.name = oddEvenRowBanding

    This will apply the oddEvenRowBanding function to this object.

  7. We see what the report looks like at this point. Press the preview button. We should obtain the following result:

What just happened?

We added a function to alternately color the rows of our report. We configured this function according to our needs and we applied it to our report.