Add a Separating Line after Every 5 Rows

Question

I have grouped data on column “state” and set the pagebreak option to “Always Excluding First” so that I can see the data related to a particular state in a separate page.

I’m trying to add a horizontal line after every 5 rows in the group. How can I do that?

I tried to add a line and set the visibility property to “Hide Element”, selected the radio button “For specific output” and wrote the expression "Birt.Math((row._rownum+1),5)!=0". At first, it looked like a solution, but for the next group, the rownum is not “zero”.

How can I reset the “rownum” to zero for every first row in the group so that I can see the horizontal line after every 5 rows (starting from the first row in that group, but not the first row in the table) in the next groups?

To say it more clear, if I have 2 groups and in the first group (which is in the first page) I have 17 rows but in the second group (which is in the second page), I have 18 rows. When I tried to add the expression for visibility (mentioned above), I could see the horizontal line every 5 rows in the first page. But in the next page, I can see the horizontal line after 3 rows (and not after 5 rows). This is because there are extra 2 rows 16, 17 in the first group and extra 3 rows 18, 19, 20 in the second group. I want to reset the rownum to zero for the first row of every group.

 

cities table:

stateid cid Name

 

42 52 Memphis

 

42 56 Nashville

 

43 49 Arlington

 

43 54 El Paso

 

43 4 Houston

 

43 8 Dallas

 

43 9 San Antonio

 

43 15 Austin

 

43 20 Paso

 

43 24 Fort Worth

 

43 72 Corpus Christi

 

43 78 Plano

 

43 94 Garland

 

Answer

It’s inconvenient to reset row number in a group with a reporting script. A better way is to prepare the report data source outside of the reporting tool. Here I choose SPL (Structured Process Language) to process the source data (where computed columns will be involved):

Solution 1: et a mark after every 5 rows.

 

A

1

$select stateid,cid,Name,0   as rowmark from cities

2

>A1.group(stateid).run(~.step(5,5).run(rowmark=1))

Final result:

undefined

Solution 2: Index the rows in each group.

 

A

1

$select stateid,cid,Name,0   as rownum from cities

2

>A1.group(stateid).run(~.run(rownum=#))

Final result:

undefined

BIRT can call an SPL script via the esProc JDBC in the way of it call a database result set. To learn more about the invocation, refer to How to Call an SPL Script in Java.