Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » GridTableViewer and sorting
GridTableViewer and sorting [message #593797] Tue, 24 February 2009 10:32 Go to next message
Christian Hauser is currently offline Christian Hauser
Messages: 189
Registered: July 2009
Senior Member
Hi all

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().

Any help is highly appreciated.
Thanks,
Christian
Re: GridTableViewer and sorting [message #872778 is a reply to message #593797] Wed, 16 May 2012 19:56 Go to previous messageGo to next message
qaouch Missing name is currently offline qaouch Missing name
Messages: 7
Registered: July 2009
Junior Member
hi
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.

thanks all
Re: GridTableViewer and sorting [message #873059 is a reply to message #872778] Thu, 17 May 2012 12:35 Go to previous message
Sharon Snyder is currently offline Sharon Snyder
Messages: 56
Registered: September 2010
Member

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.

Sharon
Previous Topic: PercentComplete invisible?
Next Topic:Nebula XViewer loads slowly when there are a lot of rows
Goto Forum:
  


Current Time: Fri Oct 31 07:55:28 GMT 2014

Powered by FUDForum. Page generated in 0.01724 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software