Skip to main content
Jump to: navigation, search

Example - Sort Table based on parameter (BIRT)

Revision as of 14:07, 20 June 2007 by (Talk | contribs) (Description)

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


This illustrates linking a report parameter to a sort condition on a table.

BIRT Version Compatibility

This example was built and tested with BIRT 2.2 RC3.

Example Files

Example Report Zipped


BIRT provides sorting at many levels. This simple example sorts a table based on a parameter. First the sample database is used to get the following query:

Select * from customers

Next a parameter is added to the report named srt, which is a static combo box with possible values of


These represent which column in the table will be used as the sort key. Next drag the query to the report canvas, which will create the table element. Select the properties for the table and choose the sorting tab. Add a sort key with the following expression for the key.

if( params["srt"].value == "firstcol" ){
} else if( params["srt"].value == "secondcol"){
} else if( params["srt"].value == "thirdcol"){

Now when executed, selecting the proper column will sort the table based on the chosen value.

Additional this example has a script that is commented out in the beforeFactory eventhandler for report. This script is shown below:


 delm = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("mytable");
 sc = StructureFactory.createSortKey();

 ph = delm.getPropertyHandle(TableHandle.SORT_PROP);

This script will add a sort condition to a named table at runtime using the DE API.


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