Thursday, March 13, 2014

Apply alternate background colors to Group headers


The instruction below is for one group header. But it can be easily extended for use with multiple group headers.

  1. Create a group in the report.
  2. At the Report level, select the Script tab.
  3. Set iRow = 0 in initialize() method of the report. “iRowcould be any variable name.
    image
  4. Return to the Layout tab of report and select the Group header row (where you want to apply style).
  5. Click on Script tab. Select onRender from Script drop down
  6. Enter the script below:
    if (iRow == 0) {
            this.getStyle().backgroundColor = "silver";
            iRow = 1;
    }  else {
            this.getStyle().backgroundColor = "white";
            iRow = 0;
    }

    image
  7. Done. Preview the report to see the changes.