Jump to content
Changes to the Jaspersoft community edition download ×

Sort group data in custom sort order


Recommended Posts



Is it possible to sort a group's data according to an application specific order?


Say I have a table column called "Priority" in the database and it stores text like "P1", "P2", "P3", etc. When I display report in table form, I want to sort these values in a preferred order like "P5", "P1", "P2" etc. This preferred order can be changed at runtime.


I know that this can be easily done using "field" function in "Order by" clause. I am looking out for a java solution as the number of records to process in database are more.


Thanks in advance for any help.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic



JasperReports does not perform any sorting on the data it receives. Sorting the data is the responsability of the data source supplier.

If you have an SQL query in the report template, you should use the ORDER BY clause to sort your data.


I hope this helps.


Link to comment
Share on other sites



Thanks for the reply. I have one more question.


Is there a way to manipulate data after the grouping and before the display? I am able to customize dataset for charts easily using ChartCustomizer. But I don't see any such interception points for groups. We are using groups to display tables.


I tried to use scriptlets. The scriptlets define methods like afterGroupInit, beforeGroupInit etc. But I don't have access to resultset or entire dataset.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...