How do I sort a Grid when using a GridTableViewer? I tried it using a
ColumnViewerSorter, but that doesn't seem to work. Furthermore, Grid
doesn't seem to have API like setSortColumn() or setSortDirection().
is there any example of GridTableViewer sorting (Not TableViewer sorting)
no use of columns indexes nor an ITableLabelProider
GridTableViewer use independent columns with for each an labelprovider.
i search but no example was found.
I am using sorting on my GridTreeViewer - I assume it would be the same/similar on the GridTableViewer. Here's what I did:
1. Created my own Comparator class that extends ViewerComparator
2. On the GridTreeViewer (gtv) I called: gtv.setComparator(myViewerComparator)
3. On each GridColumn (gc) I added a selectionListener that would get the comparator and set any information that I wanted it to know (the sort direction, the columnNumber (I had different sorting I needed to do based on the column being sorted), set the sort direction marker on the column (gc.setSort(SORTDIRECTION);
4. refresh the gridTreeViewer (gtv.refresh()).
and then the comparator would be called and I did my sort
Sorry I don't have an example code set up for you....but I hope that this helps.