Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Add multiple Detail Columns (Birt Engine)
Add multiple Detail Columns (Birt Engine) [message #366694] Wed, 21 January 2009 16:46 Go to next message
Eclipse User
Originally posted by: sadsdfd.asds.com

I am trying to write an application that adds 2 cloumns to a table. It works
fine with the first one:


....
....
table = elementFactory.newTableItem( null, 3, 1, 1, 1 );
....
....
PropertyHandle computedSet = table.getColumnBindings( );
DataItemHandle data = null;
RowHandle detail = null;
ComputedColumn cs1, cs2 = 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

// Create Detail for second column.
cs2 = StructureFactory.createComputedColumn( );
cs2.setName("lastName");
cs2.setExpression( "dataSetRow[\"lastName\"]" );//$NON-NLS-1$
computedSet.addItem( cs2 ); //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 );

// Add second column to report (ERROR!)
detail = (RowHandle) table.getDetail( ).get( 1 ); //returns the first
slot.
tcell = (CellHandle) detail.getCells( ).get( 1 );
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs2.getName( ) );
tcell.getContent( ).add( data );


// Finally add the updated table to the report design.
reportDesignHandle.getBody( ).add( table );


But that give a nullpointer exception. It assume that its because I do
..get(1) but how do I add more than one details column?
Re: Add multiple Detail Columns (Birt Engine) [message #366697 is a reply to message #366694] Wed, 21 January 2009 18:17 Go to previous messageGo to next message
Eclipse User
Originally posted by: jasonweathersby.alltel.net

Do you have 2 detail rows?
this returns a second detail row.

detail = (RowHandle) table.getDetail( ).get( 1 ); //returns the first
> slot.

try

detail = (RowHandle) table.getDetail( ).get( 0 ); //returns the first
> slot.

Jason

JS wrote:
> I am trying to write an application that adds 2 cloumns to a table. It
> works fine with the first one:
>
>
> ...
> ...
> table = elementFactory.newTableItem( null, 3, 1, 1, 1 );
> ...
> ...
> PropertyHandle computedSet = table.getColumnBindings( );
> DataItemHandle data = null;
> RowHandle detail = null;
> ComputedColumn cs1, cs2 = 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
>
> // Create Detail for second column.
> cs2 = StructureFactory.createComputedColumn( );
> cs2.setName("lastName");
> cs2.setExpression( "dataSetRow[\"lastName\"]" );//$NON-NLS-1$
> computedSet.addItem( cs2 ); //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 );
>
> // Add second column to report (ERROR!)
> detail = (RowHandle) table.getDetail( ).get( 1 ); //returns the first
> slot.
> tcell = (CellHandle) detail.getCells( ).get( 1 );
> data = elementFactory.newDataItem( null );
> data.setResultSetColumn( cs2.getName( ) );
> tcell.getContent( ).add( data );
>
>
> // Finally add the updated table to the report design.
> reportDesignHandle.getBody( ).add( table );
>
>
> But that give a nullpointer exception. It assume that its because I do
> .get(1) but how do I add more than one details column?
Re: Add multiple Detail Columns (Birt Engine) [message #366702 is a reply to message #366697] Thu, 22 January 2009 06:50 Go to previous message
Eclipse User
Originally posted by: sadsdfd.asds.com

"Jason Weathersby" <jasonweathersby@alltel.net> wrote in message
news:gl8af2$5uf$2@build.eclipse.org...
> Do you have 2 detail rows?
> this returns a second detail row.
>
> detail = (RowHandle) table.getDetail( ).get( 1 ); //returns the first
> > slot.
>
> try
>
> detail = (RowHandle) table.getDetail( ).get( 0 ); //returns the first
> > slot.
>
> Jason
>


No I have one details row, but would like to access/write-to the second
column of that details row. To access the second column I just needed to do:


// Add Second Column to report.
detail = (RowHandle) table.getDetail( ).get( 0 ); //returns the first
slot.
tcell = (CellHandle) detail.getCells( ).get( 1 ); // access second column.
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs2.getName( ) );
tcell.getContent( ).add( data );
Previous Topic:Header on a cross-tab row?
Next Topic:Report Viewer Problem in Linux
Goto Forum:
  


Current Time: Fri Aug 22 17:45:54 EDT 2014

Powered by FUDForum. Page generated in 0.04243 seconds