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)
Global Highlighting Rule
SarahJacob
I have 20 plus reports with dozens of numbers and values in tables. I'd like all negative numbers to be highlighted in RED. How do I create a condition/highlight at the library/style level to apply to all reports and cells versus the single cell condition approach which is slowly killing me? I'm ok adding Java or JavaScript to my solution.
Find more posts tagged with
Comments
SarahJacob
Still outstanding. Does anyone know the answer to this simple problem? I'm ok with using code to get to the solution.
Thanks.
mwilliams
I don't see an easy way to do this. It looks like defining that highlight for all numerical fields in your design is the way to go. It doesn't look like a style will even do it, that I saw.
SarahJacob
Michael,
Thanks for your answer, I appreciate it.
I know that BIRT takes plug-ins, do you think we could achieve it with a plug-in? We have programmers so, could you point to an example to get me started?
If it works, we'll contribute it back your way.
Many thanks,
Sarah
mwilliams
The only idea I could come up with was stepping through all elements, so I asked a colleague if he had anything for this. He gave me the following script. Take a look. It should go in the beforeFactory method:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage( Packages.org.eclipse.birt.report.model.api );
var rdh = reportContext.getDesignHandle();
importPackage(Packages.org.eclipse.birt.report.model.api.elements);
importPackage(Packages.org.eclipse.birt.report.model.api.elements.structures);
shBody = rdh.getBody();
slotIterator = shBody.iterator();
// To retrieve top-level report items, iterate over the body.
while (slotIterator.hasNext()) {
shContents = slotIterator.next();
// To get the contents of the top-level report items,
// instantiate slot handles.
if (shContents instanceof GridHandle) {
grid = shContents;
parseGrid( grid );
}
if (shContents instanceof ListingHandle) {
list = shContents;
parseList( list );
}
}
function parseGrid(grid){
grRows = grid.getRows( );
rowIterator = grRows.iterator( );
parseRow( rowIterator);
}
function parseList( list){
grRows = list.getHeader();
rowIterator = grRows.iterator( );
parseRow( rowIterator);
grRows = list.getDetail();
rowIterator = grRows.iterator( );
parseRow( rowIterator);
grRows = list.getFooter();
rowIterator = grRows.iterator( );
parseRow( rowIterator);
grRows = list.getGroups();
rowIterator = grRows.iterator( );
parseRow( rowIterator);
}
function parseRow( rowIterator){
while (rowIterator.hasNext()) {
// Get RowHandle objects.
rowSlotContents = rowIterator.next();
// To find the image element, iterate over the grid.
cellSlot = rowSlotContents.getCells( );
cellIterator = cellSlot.iterator( );
while ( cellIterator.hasNext( ) ) {
// Get a CellHandle object.
cellSlotContents = cellIterator.next( );
cellContentSlot = cellSlotContents.getContent( );
cellContentIterator = cellContentSlot.iterator( );
while (cellContentIterator.hasNext( )) {
// Get a DesignElementHandle object.
cellContents = cellContentIterator.next( );
// Check that the element is an image.
if( cellContents instanceof DataItemHandle){
cellContents.setOnRender("if ( this.getValue() < 30 ){this.getStyle().color=\"red\";}");
}
if (cellContents instanceof GridHandle ){
parseGrid( cellContents);
}
if (cellContents instanceof ListingHandle ){
parseList( cellContents);
}
}
}
}
}
</pre>