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 Go to next message
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( );

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();
	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 );
	tcell.getContent( ).add( mydata );

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

reportDesignHandle.getBody( ).add( table );
Re: Hiding column via script [message #1805890 is a reply to message #1791989] Fri, 26 April 2019 16:30 Go to previous messageGo to next message
Vandna Patel is currently offline Vandna PatelFriend
Messages: 1
Registered: April 2019
Junior Member
Did you ever manage to do this? If you did, can you please share how you did it. I am trying to hide a column and label dynamically to remove white space on the report if the value fetched is null, need help in trying to accomplish this.

I have already used visibility property for each colum and added expression there but report leaves spaces when value is null.
Re: Hiding column via script [message #1807664 is a reply to message #1805890] Wed, 05 June 2019 19:32 Go to previous message
Norma Ramey is currently offline Norma RameyFriend
Messages: 5
Registered: June 2018
Junior Member
Am I over simplifying this by suggesting the use of the Visibility property on the column? It is available on the column of a table or grid. Just need to create the Boolean expression to apply the property.
Previous Topic:Text Output not showing correctly in PDF Output
Next Topic:Multiple themes - second theme not found at runtime
Goto Forum:

Current Time: Tue Oct 15 21:09:33 GMT 2019

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

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

Back to the top