4

Currently I'm developing a project (JSF 2.0, RichFaces 3.3.3) in which I have to get a 2-columns DataTable with multiple column sorting enabled (I've done this already via sortMode="Multi" property) but, unlike single column sorting, in the case of multiple columns is impossible for me to release the column or columns for which the sorting is being performed (this is done in single column case by clicking on other column header).

The sort order gets locked during the session: even when switching between tabs, my web application is maintaining the current columns sorting settings. I need to restore this configuration within the session to allow the user to select other sort order, because at present the only way to reset it is to log off and re-enter.

Example: When the user makes a sorting by column A and then by column B (or vice-versa), and given that I'm using sortPriority property too (it's a requirement I can't change), the couple A-B combination gets locked while current session is open. When the user needs to sort the DataTable by only one column (sort by either A or B) it's impossible to get this in the same session after making a multi-column sorting.

Is there some way to achieve the "combined-column-sort release" I need?

Thanks in advance.

UPDATE:

I figured out that with only two data columns in my datatable the only way to do this is by toggling somehow the sortMode property between "Multi" and "Single" values. In such a way, I could guarantee that being in the single-column sorting mode it will release the combination of columns.

Has anyone worked successfully with the situation of having to ​​assign values to rich:dataTable component properties in runtime with javascript?

Francisco Alvarado
  • 2,815
  • 2
  • 26
  • 51

1 Answers1

0

Check out the sortBy and sortOrder attributes of rich:dataTable and rich:column. By setting sortOrder="UNSORTED" on the rich:column it should clear the sorting of that column. You may also be able to set sortOrder="UNSORTED" and/or sortBy="" on the rich:dataTable itself for a simpler solution (although I haven't tried it). You could do this in the JavaScript onLoad function or in a bean that has the attributes bound to its properties.

That should hopefully be a little more elegant than having to play with the sortMode :)

Gyan aka Gary Buyn
  • 12,242
  • 2
  • 23
  • 26