Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Example - Sort Table based on parameter (BIRT)

< 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.

I tried above example and it works successfully. I am having a problem in excel format. I excel when I sort any column it opens a new excel file with sorted data. Can it be done within same excel file?? Pls. help me in this regard. I would be very much thankful.

Back to the top