Take the 2-minute tour ×

I'm new in Birt scripting and need help with some script. I want to merge cells in a table row on row create if they contain equal data. For example this table

|  id1  |   2   |   4   |
|  id2  |   5   |   5   |

should look like

|  id1  |   2   |   4   |
|  id2  |       5       |

I've found some examples and now I can for example change row background based on row data onrowcreate:

if (this.getRowData().getExpressionValue(1) == "id1")
this.getStyle().backgroundColor = "red";

if (this.getRowData().getExpressionValue(1) == "id2")
this.getStyle().backgroundColor = "blue"; 

And another example shows how to merge cells in table header beforeFactory:

importPackage( Packages.org.eclipse.birt.report.model.api );
elementFactory = reportContext.getDesignHandle().getElementFactory();
var mytable = reportContext.getDesignHandle().findElement("mytable");
var myheader = mytable.getHeader( ).get( 0 );
tcell = myheader.getCells( ).get( 1 ).drop();
tcell = myheader.getCells( ).get( 0 );

Both examples work fine, but i need to check if there same data in cells before merging them, can I do something similar to beforeFactory script onrowcreate, or may be there is different ways.

Thank you!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Once the table is created, it's not possible to merge cells, so this would need to be done in the beforeFactory event, which doesn't work for you, because this runs before it sees your datasets.

Depending on how complex your table is, it might make sense to create 2 detail rows, one with the merged columns and one without. Then you can dynamically hide the detail row that you don't want to use based on the data in your row.

share|improve this answer
Thank you! It works great. I've added second detail row, and set visibility conditions for my two detail rows, first is visible when cells values are different, and second is visible when they are equal. –  Stingo82 Apr 13 '13 at 17:46

Your Answer


