Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Hiding Table Columns within script
Hiding Table Columns within script [message #1791999] Mon, 09 July 2018 14:50
Alexander Scott is currently offline Alexander ScottFriend
Messages: 6
Registered: July 2018
Junior Member
I am able to hide the column in HTML via assigning a style with "display:none;", but I have the issue that when exporting to Excel I get an ugly empty column.

Is there a way to assign a Hide Rule to a header/detail?

I have found this: https://wiki.eclipse.org/Add_Visibility_Rule_in_beforeFactory_(BIRT)
, but unable to get it working directly against a header/detail element.

My beforeFactory script so far:
importPackage( Packages.org.eclipse.birt.report.model.api );
importPackage(Packages.org.eclipse.birt.report.model.api.simpleapi);

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);
	cs1.setExpression( "dataSetRow[" +i +"]" );
	computedSet.addItem( cs1 );

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

	if (i == 2) {
		headercell.setStyleName("hidden");
		hr = StructureFactory.createHideRule();
		hr.setFormat("html");
		hr.setExpression("false;");
		ph = headercell.getContainer().getPropertyHandle("visibility");
		ph.addItem(hr);
		detailcell.setStyleName("hidden");
		cs1.setAllowExport(false);
	}
}

reportDesignHandle.getBody( ).add( table );
Previous Topic:Image not showing on PDF
Next Topic:UNION ALL - XML
Goto Forum:
  


Current Time: Sat Apr 27 02:31:12 GMT 2024

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

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

Back to the top