Search code examples
reportdesignerbirt

BIRT Alternate Row Color Reset in each Group


I'm trying to highlight (silver background color) alternate rows in a BIRT report which has groups. Although I have implemented this solution the problem is that each group does not always start with a highlighted row. I want the highlighting rows reset for each group.

The way it is now:

Department A
  Highlight
  not highlight
  Highlight

Department B
  not highlight
  Highlight

What I want is:

Department A
  Highlight
  not highlight
  Highlight

Department B
  Highlight
  not highlight

Is there any way to acheive this?

I am using BIRT 4.2.2 and the dataset is a single sql query, grouped by department.

thanks


Solution

  • The solution is similar to the one linked, but additionally you need to define a running count of rows within a group.

    To do so:

    • In the report designer Layout view, select the whole table (by clicking just below the bottom of the report on the left hand side).
    • In the Property Editor for the Table, select the Binding tab.
    • In the Binding tab, click the Add Aggregation... button (on the right) and enter the following options:
      • Column Binding Name: something meaningful (such as groupRow);
      • Data Type: Integer;
      • Function: RUNNINGCOUNT;
      • Aggregate On: Group (and select the appropriate group).

    Then amend the highlighting expression for the row to be:

    row["groupRow"] % 2 Not Equal to 0
    

    (instead of row[0] % 2 Equals 0.)

    If you now preview the report, you should find the odd-numbered rows within each group highlighted, as required.