Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Add Visibility Rule in beforeFactory (BIRT)

< To: Report Developer Examples (BIRT)
This example is Bugzilla ID 190059. If you would like to contribute an example see the example contribution guidelines.

Introduction

This example illustrates calling the BIRT Design Engine API from the beforeFactory Script to add a map rule to a report element.

BIRT Version Compatibility

This example was built and tested with BIRT 2.1.2.

Example Files

Example Report Zipped

Description

This example uses the DE API to locate a named report Data Element. Once located, the DE API is used to create and add a hide rule to the report element.

The beforeFactory script is listed below.

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

delm = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("QTYELEMENT");

hr = StructureFactory.createHideRule();
hr.setFormat("html");
hr.setExpression("if( row[\"QUANTITYORDERED\"] > 30 ){true;}else{false;}");
ph = delm.getPropertyHandle("visibility");
ph.addItem(hr); 

The variable delm is set to the report element named QTYELEMENT. This means the data element in question must be named using the name property in the Property Editor. The hr variable is a hide rule that is created using the DE API Structure Factory. The hide rule is then applied to the data element using a Property Handle.

In this example the quantity field is hidden for values greater than 30.

Comments

Please enter comments below by selecting the edit icon to the right. You will need a Bugzilla account to add comments.


Back to the top