Jump to content

BIRT Developer Center Download


File Information

  • Submitted: Nov 01 2013 06:46 AM
  • Last Updated: Apr 23 2014 07:07 AM
  • File Size: Unknown
  • Views: 27855
  • Downloads: 0
  • Approved by: kclark
  • Approved on: 23 April 2014 - 07:07 AM
  • Summary: Dynamic column sorting in Birt Report.
  • Content Type: Designs & Code
  • BIRT Version: 4.2

Dynamic Column Sorting

- - - - -

Hi everyone,
Here I am going to explain some points to implement dynamic column sorting in birt 4.0.

1) Open report.

2) Open Outline window.

3) Create “SortKey” & “SortDir” report parameter.(Deselect “Is Required” & select “hidden”)

4) Here we are talking about column name which is same as created in dataset. You have to expand data set to see column names.

5) Select table which we are using to display result. Open property editor window . Click on General. Give any name to table it must be related to report.

6) Open report click on layout which is located at bottom left side.

7) Then click on Script. Select “ beforeFactory” in drop down which is at top left of the report.
table = reportContext.getDesignHandle().findElement("table");

if (params["SortDir"].value == "Desc"){
Note: Here table is a name of table that you have given in point 5.

8) Click on header where you want to add sorting.
->Property Editor ->Properties - > hyperlink-> click Edit “Link To”.

Select Drill-through.

Select Report Design to current report by browsing.

In report parameters Click on add – Select “SortDir” past Value
if (params["SortKey"].value == "column") {
  if (params["SortDir "].value == "Asc") {
Here column is same as explained in point 4. It will change for every column.

9) Again add ,Select SortKey . In this case value will be name of column in “”(Double quote);

10) Again add select any value from drop down. While adding value to this click on fx.->Report params -> all -> Select same parameter which we have selected in dropdown. It means we are assigning value to itself. Repeat same procedure for all parameters.

Except “__htmlPagination”.

11) Final Click on layout then select table . In property Editor -> Sorting -> add – Update Key to
if ( params["SortKey"].value == " columnName "){
}else if
12) Save report & run it.

13) For next columns you have to repeat 8,9,10&11. No change in 1-7.

Kushal Palli
Sep 02 2015 07:29 PM

Hello Sachin,

                      i have followed the steps but unfortunately it didn't work. can you send some more helpful information about the same like in the form of screenshots or files. Thanks.

Sep 07 2015 08:49 PM

Thank you for the valuable post.


I would like to add one HTML link/button per table column heading, so that users can sort ascending or descending. 


Please let me know given an already-designed table, if it is possible to add such links duirng onPrepare of the table or I have to use Design Engine for that.


If it is possible using onPrepare please guide me to a link or some samples codes.


Thank you,

I tried these steps.In step 11,Sort Direction field is mandatory,If choose ascending,while clicking on header the list will come as ascending order.After clicking, the data will come randomly,its not coming in descending order,Can you please help for dynamic sorting?

Other files you may be interested in ..

  • 997 Total Files
  • 8 Total Categories
  • 153 Total Authors
  • 31706 Total Downloads
  • Joyplot in iHub Latest File
  • Clement Wong Latest Submitter

1 user(s) are online (in the past 1 minutes)

0 members, 1 guests, 0 anonymous users