Thursday, November 26, 2009

My First Script in BIRT

Yeah, I got it finally. I added a piece of ECMAScript to a BIRT report. Actually, it just does one very simple thing: highlighting one row if the value of a column fulfills a condition.

Created a datasource (MySQL database on my computer) and a dataset. Business as usual, nothing fancy. The dataset is actually a table consisting of two columns, one is the primary key, the second is the value.
On the Layout tab, I clicked the value column's value row, and just added this code to the onRender method (the Help says: "Script executed when the element is prepared for rendering in the Presentation engine"):

var val = this.getValue();
if (val == "boo") {
this.getStyle().backgroundColor = "#AAAAAA";
}

And voilá:




This BIRT thing is not bad, after all.