Skip to main content



      Home
Home » Archived » BIRT » GROUP on using the engine?
GROUP on using the engine? [message #366747] Tue, 27 January 2009 17:49 Go to next message
Eclipse UserFriend
Originally posted by: sadsdfd.asds.com

When a field in a table is group'ed on its added to the TOC. But how is a
field group'ed on using the BIRT Engine? In the below code I would like to
group on firstName:

PropertyHandle computedSet = table.getColumnBindings( );
DataItemHandle data = null;
RowHandle detail = null;
ComputedColumn cs1, cs2, cs3 = null;

// Create Detail for first column.
cs1 = StructureFactory.createComputedColumn( );
cs1.setName("firstName");
cs1.setExpression( "dataSetRow[\"firstName\"]" );//$NON-NLS-1$
computedSet.addItem( cs1 ); //Add an item to the end of a list property


// Add First Column to report.
detail = (RowHandle) table.getDetail( ).get( 0 ); //returns the first
slot.
tcell = (CellHandle) detail.getCells( ).get( 0 );
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs1.getName( ) );
tcell.getContent( ).add( data );


I have tried something like:

tcell.setEventHandleClass("firstName");

But it seems that the kind of grouping I want is not defined for the object
CellHandle.
Re: GROUP on using the engine? [message #366748 is a reply to message #366747] Wed, 28 January 2009 00:19 Go to previous message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Take a look at this code, specifically the TableGroupHandle.

TableHandle table = elementFactory.newTableItem( null, 3, 1, 1, 1 );
table.setProperty( IStyleModel.TEXT_ALIGN_PROP,
DesignChoiceConstants.TEXT_ALIGN_CENTER );
table.setWidth( "80%" );//$NON-NLS-1$
table.setProperty( IReportItemModel.DATA_SET_PROP, "ds" );//$NON-NLS-1$

ColumnHandle ch = (ColumnHandle)table.getColumns().get(0);
//ch.setProperty("Width", "3in");
ch.getWidth().setStringValue("3in");

PropertyHandle computedSet = table.getColumnBindings( );
cs1 = StructureFactory.createComputedColumn( );
cs2 = StructureFactory.createComputedColumn( );
cs3 = StructureFactory.createComputedColumn( );
cs4 = StructureFactory.createComputedColumn( );
cs5 = StructureFactory.createComputedColumn( );

cs1.setName("ORDERNUMBER");
cs1.setExpression( "dataSetRow[\"ORDERNUMBER\"]" );
cs1.setDataType("Integer");
computedSet.addItem( cs1 );

cs2.setName("Product");
cs2.setExpression( "dataSetRow[\"PRODUCTCODE\"]" );
cs2.setDataType("String");
computedSet.addItem( cs2 );

cs3.setName("Amount");
cs3.setExpression( "dataSetRow[\"QUANTITYORDERED\"]");
cs3.setDataType("Integer");
computedSet.addItem( cs3 );

cs4.setName("TotalAmount");
cs4.setExpression( "Total.sum(dataSetRow[\"QUANTITYORDERED\"])" );
cs4.setDataType("Integer");
//cs4.setAggregateOn("All");
computedSet.addItem( cs4 );

cs5.setName("GroupTotalAmount");
cs5.setExpression( "Total.sum(dataSetRow[\"QUANTITYORDERED\"])" );
cs5.setDataType("Integer");
cs5.setAggregateOn("MyGroup");
computedSet.addItem( cs5 );



// Header
RowHandle header = (RowHandle) table.getHeader( ).get( 0 );

CellHandle tcell = (CellHandle) header.getCells( ).get( 0 );
tcell.getWidth().setStringValue("3in");
LabelHandle label = elementFactory.newLabel( null );
label.setText( "Order" );//$NON-NLS-1$
tcell.getContent( ).add( label );

tcell = (CellHandle) header.getCells( ).get( 1 );
label = elementFactory.newLabel( null );
label.setText( "Product" );//$NON-NLS-1$
tcell.getContent( ).add( label );

tcell = (CellHandle) header.getCells( ).get( 2 );
label = elementFactory.newLabel( null );
label.setText( "Amount" );//$NON-NLS-1$
tcell.getContent( ).add( label );






// Table Group
TableGroupHandle group = elementFactory.newTableGroup( );
group.setName("MyGroup");
group.setKeyExpr( "row[\"ORDERNUMBER\"]" );
group.setInterval("none");
group.setSortDirection("asc");

table.getGroups( ).add( group );


RowHandle groupHeader = elementFactory.newTableRow( 3 );
tcell = (CellHandle) groupHeader.getCells( ).get( 0 );
DataItemHandle data = elementFactory.newDataItem( null );

data.setResultSetColumn( cs1.getName( ) );
tcell.getContent( ).add( data );
group.getHeader( ).add( groupHeader );

RowHandle groupFooter = elementFactory.newTableRow( 3 );
tcell = (CellHandle) groupFooter.getCells( ).get( 2 );
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs5.getName( ) );
tcell.getContent( ).add( data );

group.getFooter( ).add( groupFooter );



// Detail
RowHandle detail = (RowHandle) table.getDetail( ).get( 0 );
//tcell = (CellHandle) detail.getCells( ).get( 0 );
//data = elementFactory.newDataItem( null );
//data.setResultSetColumn( cs1.getName( ) );
//tcell.getContent( ).add( data );
data = elementFactory.newDataItem( null );

tcell = (CellHandle) detail.getCells( ).get( 1 );
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs2.getName( ) );
tcell.getContent( ).add( data );

tcell = (CellHandle) detail.getCells( ).get( 2 );
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs3.getName( ) );
tcell.getContent( ).add( data );



RowHandle footer = (RowHandle) table.getFooter( ).get( 0 );
tcell = (CellHandle) footer.getCells( ).get( 2 );
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs4.getName( ) );
tcell.getContent( ).add( data );




reportDesignHandle.getBody( ).add( table );


Jason

JS wrote:
> When a field in a table is group'ed on its added to the TOC. But how is
> a field group'ed on using the BIRT Engine? In the below code I would
> like to group on firstName:
>
> PropertyHandle computedSet = table.getColumnBindings( );
> DataItemHandle data = null;
> RowHandle detail = null;
> ComputedColumn cs1, cs2, cs3 = null;
>
> // Create Detail for first column.
> cs1 = StructureFactory.createComputedColumn( );
> cs1.setName("firstName");
> cs1.setExpression( "dataSetRow[\"firstName\"]" );//$NON-NLS-1$
> computedSet.addItem( cs1 ); //Add an item to the end of a list property
>
>
> // Add First Column to report.
> detail = (RowHandle) table.getDetail( ).get( 0 ); //returns the first
> slot.
> tcell = (CellHandle) detail.getCells( ).get( 0 );
> data = elementFactory.newDataItem( null );
> data.setResultSetColumn( cs1.getName( ) );
> tcell.getContent( ).add( data );
>
>
> I have tried something like:
>
> tcell.setEventHandleClass("firstName");
>
> But it seems that the kind of grouping I want is not defined for the
> object CellHandle.
>
Previous Topic:Modifying a .rptdesign file?
Next Topic:Rotate of log files of the Birt reportEngine
Goto Forum:
  


Current Time: Fri Nov 07 14:16:53 EST 2025

Powered by FUDForum. Page generated in 0.03380 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top