Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to change cell format from grid scripts
germobirt
Hi,<br />
<br />
using Birt 2.6.2 I wanna change cell borders and background colors in a grid.<br />
<br />
If I use the onPrepare script of a certain cell, I can change things this way.<br />
<strong class='bbc'>this.getStyle().backgroundColor = "gray"</strong><br />
<br />
If I use the onPrepare script of the grid, I can't.<br />
I can get the cell this way<br />
<strong class='bbc'><br />
grid = reportContext.getDesignHandle().findElement("myGrid");<br />
row = grid.getRows().get(0);<br />
cell = row.getCells().get(0);</strong><br />
<br />
I can add new elements in the cell<br />
<strong class='bbc'>cell.getContent().add();</strong><br />
<br />
But this returns null<br />
<strong class='bbc'>cell.getStyle();</strong><br />
<br />
How can I change the formatting of the cells of my grid, from <span class='bbc_underline'>within the grid script</span>?<br />
<br />
regards
Find more posts tagged with
Comments
bricombs
Good Day
You geed to get a StyleHandel for the cell to change the background color from script in the Grid. The following worked for me in the Grid onPrepare.
grid = reportContext.getDesignHandle().findElement("myGrid");
row = grid.getRows().get(0);
cell = row.getCells().get(0);
cellStyle = cell.getPrivateStyle();
bgColor = cellStyle.getBackgroundColor();
bgColor.setRGB(0xA9A9A9 );
germobirt
Hi,<br />
<br />
and thanks a lot!<br />
That's a leap for me.<br />
<br />
<strong class='bbc'>getPrivateStyle()</strong><br />
<br />
I've never read anything about this before.<br />
<br />
best regards
bricombs
Good Day
Glad I could help. Actually I found the answer in the ?Integrating and Extending BIRT? (ISBN-10: 0321772822) book. It is a good reference book if you are doing a lot of scripting.