Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Hiding column via script
Hiding column via script [message #1791989] Mon, 09 July 2018 11:25
Alexander Scott is currently offline Alexander ScottFriend
Messages: 6
Registered: July 2018
Junior Member
I am having a random size resultset returned. I have managed to programatically create a table of X width. What I now need to do is add a visibility expression to hide the column when there is no data.

Can anyone give me a hand? I assume I need to add some sort of "visibility" property with an expression as the value?

What I have so far;

importPackage( Packages.org.eclipse.birt.report.model.api );

reportContext.setPersistentGlobalVariable("COLUMN_SIZE", "20");
var COLUMN_SIZE = reportContext.getPersistentGlobalVariable("COLUMN_SIZE");

reportDesignHandle = reportContext.getReportRunnable().designHandle.getDesignHandle();
elementFactory = reportDesignHandle.getElementFactory();
dataSetHandle = elementFactory.newScriptDataSet( "Data Set" );
dataSetHandle.setDataSource( "Data Source" );

reportDesignHandle.getDataSets( ).add( dataSetHandle );

// public TableHandle newTableItem(String name, int columnNum, int headerRow, int detailRow, int footerRow) {
table = elementFactory.newTableItem( "table1", COLUMN_SIZE, 1, 1, 0 );
table.setWidth( "80%" );
table.setProperty( "dataSet", "Data Set" );

computedSet = table.getColumnBindings();

for ( var i = 0; i < COLUMN_SIZE; i++ ) {
	cs1 = StructureFactory.createComputedColumn();
	cs1.setName(i);
	if (i == 2) {
  	  cs1.setExpression( "false" );
  	  cs1.setFilterExpression( "true" );
  	  cs1.setProperty("visibility", "false");
	} else {
	  cs1.setExpression( "dataSetRow[" +i +"]" );
	}
	expression = new Expression("valueExpr", "false");
	cs1.setExpressionProperty("visibility", expression); // does not work
	
	computedSet.addItem( cs1 );

	// Header
	myheader = table.getHeader( ).get( 0 );
	tcell = myheader.getCells( ).get( i );
	mylabel = elementFactory.newLabel( i );
	mylabel.setText( "H" + i );
	tcell.getContent( ).add( mylabel );
	
	// detail
	mydetail =  table.getDetail( ).get( 0 );
	tcell = mydetail.getCells( ).get( i );
	mydata = elementFactory.newDataItem( null );
	mydata.setResultSetColumn(i);	
	tcell.getContent( ).add( mydata );

	if (cs1.getName() == "two") {
		tcell == null
	}
	
}

reportDesignHandle.getBody( ).add( table );
Previous Topic:Change report title,author using data from database
Next Topic:Image not showing on PDF
Goto Forum:
  


Current Time: Mon Nov 19 21:37:57 GMT 2018

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

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

Back to the top