Tobago Demo

Menu

Sheet Sorting

Sorting can be enable via the sortable attribute in the <tc:column/>. A custom sorting implementation can be set in the sortActionListener attribute in the <tc:sheet/>.

It's important to have a component inside the <tc:column/>, e. g. <tc:out value="#{object.name}"/>. If there is only a fragment like #{object.name}, sorting will not be possible!

Tag Library Documentation: <tc:sheet/> | <tc:column/>

Basics

In this example, the sortable attribute is 'true' for all columns. Notice, that there are negative periods.

<tc:column label="Name" sortable="true">
NamePeriod (Days)Discovery Year
Sun0.0
Mercury87.97
Venus224.7
Earth365.26
Rows 1 to 4 of 88
  • Page 1 of 22

Custom Sorting

All columns in this sheet can be sorted. A custom sorting implementation is set. Now, the sign for period numbers is ignored by sorting.

<tc:sheet value="#{sheetController.solarList}" var="solarobject" rows="4" sortActionListener="#{sheetController.sheetSorter}"> <tc:column id="namecol" label="Name" sortable="true"> ...
NamePeriod (Days)Discovery Year
Sun0.0
Mercury87.97
Venus224.7
Earth365.26
Rows 1 to 4 of 88
  • Page 1 of 22

Multi-Column Sorting

With the attribute maxSortColumns it is possible to visualize more than one sorting column. In this example you can sort by 3 columns. It works by clicking the column header in the reverse order. It's also possible to use ascending and descanding orders mixed.

It is also possible to use this via the API from the application like the button below shows.

NameSpeciesGenderAge
JamesGoatmale18
RileyCatfemale23
JamesPigmale20
RileyGoatfemale25
RileyPigmale26
JamesCatfemale17
RileyCatmale22
JamesPigfemale21
JamesGoatfemale19
AveryPigfemale15
JamesCatmale16
AveryCatmale10
RileyGoatmale24
AveryGoatmale12
RileyPigfemale27
AveryGoatfemale13
AveryCatfemale11
AveryPigmale14
© 2005-2024 Apache Software Foundation, Licensed under the Apache License, Version 2.0.