Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to define group property using BIRT design Engine API
ashish13
Hi,
I can define the row header and cell property using below code, but how can i define the group property. Please suggest.
// table header
RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );
for( int i=0; i < cols.size(); i++){
LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );
label1.setText((String)cols.get(i));
CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
cell.getContent( ).add( label1 );
StyleHandle styleHandle = cell.getPrivateStyle();
styleHandle.setProperty(StyleHandle.BACKGROUND_COLOR_PROP, "red");
styleHandle.setProperty(StyleHandle.FONT_FAMILY_PROP, "Arial");
styleHandle.setProperty(StyleHandle.FONT_SIZE_PROP, 14);
}
// table detail
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
for( int i=0; i < cols.size(); i++){
CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );
data.setResultSetColumn( (String)cols.get(i));
cell.getContent( ).add( data );
StyleHandle styleHandle = cell.getPrivateStyle();
ColorHandle colorHandle = styleHandle.getBackgroundColor();
colorHandle.setRGB(0xFF8888);
}
Find more posts tagged with
Comments
johnw
<pre class='_prettyXprint _lang-auto _linenums:0'>// Table Group
TableGroupHandle group = elementFactory.newTableGroup( );
group.setKeyExpr( "row[\"Product\"]" );//$NON-NLS-1$
table.getGroups( ).add( group );
RowHandle groupHeader = elementFactory.newTableRow( 3 );
tcell = (CellHandle) groupHeader.getCells( ).get( 0 );
tcell.setDrop( DesignChoiceConstants.DROP_TYPE_DETAIL );
DataItemHandle data = elementFactory.newDataItem( null );
data.setStyleName( "Data" );//$NON-NLS-1$
data.setResultSetColumn( cs2.getName( ) );
tcell.getContent( ).add( data );
group.getHeader( ).add( groupHeader );
RowHandle groupFooter = elementFactory.newTableRow( 3 );
tcell = (CellHandle) groupFooter.getCells( ).get( 0 );
tcell.setProperty( StyleHandle.BORDER_BOTTOM_COLOR_PROP, "#FF8000" );//$NON-NLS-1$
tcell.setProperty( StyleHandle.BORDER_BOTTOM_STYLE_PROP,
DesignChoiceConstants.LINE_STYLE_SOLID );
tcell.setProperty( StyleHandle.BORDER_BOTTOM_WIDTH_PROP,
DesignChoiceConstants.LINE_WIDTH_THIN );
tcell = (CellHandle) groupFooter.getCells( ).get( 1 );
tcell.setProperty( StyleHandle.BORDER_BOTTOM_COLOR_PROP, "#FF8000" );//$NON-NLS-1$
tcell.setProperty( StyleHandle.BORDER_BOTTOM_STYLE_PROP,
DesignChoiceConstants.LINE_STYLE_SOLID );
tcell.setProperty( StyleHandle.BORDER_BOTTOM_WIDTH_PROP,
DesignChoiceConstants.LINE_WIDTH_THIN );
tcell = (CellHandle) groupFooter.getCells( ).get( 2 );
tcell.setProperty( StyleHandle.BORDER_BOTTOM_COLOR_PROP, "#FF8000" );//$NON-NLS-1$
tcell.setProperty( StyleHandle.BORDER_BOTTOM_STYLE_PROP,
DesignChoiceConstants.LINE_STYLE_SOLID );
tcell.setProperty( StyleHandle.BORDER_BOTTOM_WIDTH_PROP,
DesignChoiceConstants.LINE_WIDTH_THIN );
group.getFooter( ).add( groupFooter );</pre>
johnw
One thing to be careful of, when you write out the report design, a new table binding will be created for whatever is referenced in the key expr. So be careful how you define it.
ashish13
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="98578" data-time="1333570003" data-date="04 April 2012 - 01:06 PM"><p>
One thing to be careful of, when you write out the report design, a new table binding will be created for whatever is referenced in the key expr. So be careful how you define it.<br /></p></blockquote>
<br />
Thanks John for your reply. Can you explain more regarding the table binding based on key expr. I have not much idea regarding BIRT.<br />
<br />
Thanks in advance,<br />
Ashish
johnw
When you create a TableGroupHandle, this is basically creating the Group Definition that you get as a result of using the add group dialog in the designer. So all of the same properties are available (expression, sort, filter, etc). The KeyExpr is the expression that grouping occurs on. This is the same as in the dialog. You then add it to the groups slot in the table.