changing the initial sort direction of a table column to DESC
changing the initial sort direction of a table column to DESC
When I click on one of the TableColumn that has sorting enabled (using Table/TableColumn API) but not sorted initially, the first sort is always ASC. Is there any option to change the first sort direction on clicking a column header to DESC when I click first time on the TableColumn header.
That worked for showing the sorting icons on the column header after the table is rendered initially which is very helpful from the usability point of view to know the sort direction. But, in case of using Table, clicking on any other column that is not part of Deferred command, first sorts the table by ASC.
For Example, if I have 5 columns in a table. I sort the table by 3 rd column in ASC and show the sorting Icon after the table is rendered as shown below with the solution that you have provided in the previous thread
Then user clicks on column 1 of the table. Then, the column values are sorted by ASC first. Is there any way, to make this sorted by DESC first. To resolve this, I tried adding the following to the DeferredCommand which provided a work around for me. (sorting column 1 by ASC when table is rendered, so user click once again makes it DESC)
But, when I switch clicking between sorting of different columns, every column remembers the last sort I have made. Basically this Sorting toggles rather than resetting after clicking another column. Is there any easiest way of resetting sorting of a column after clicking another column to the one mentioned in DeferredCommand.
I may have led you down the wrong path - I think this might be the solution....
1) use Table.sort() in a deferred command to ensure it is rendered and it will do the getTableHeader().sort(index, sortDir) for you.
2) extend TableColumn class and override the default protected SortDir sortDir = SortDir.NONE to be whatever you want the default to be for every column.
The solution in item (1) does resolve the issue partially and thanks for your input. But I am still looking in to resolution for 'Sorting toggles rather than resets after clicking another column'.
Seems like Table kinda has bug (more of a usability issue than code) and I doubt it would be fixed considering Grid is where all the effort for the new table-like widget is going to be. I'm guessing it won't be long before a working gird with all the correct behaviour will be provided. The SVN has the fundamentals of a gird already working in test...
My best advice (for a short-term fix) would be to study the workings of Table and extend and change the issue behaviour - I'd guess it wouldn't be that hard.