问题
Our application is an RCP appliction and needs to display table of several thousands items. For this reason, we're using SWT.VIRTUAL
in our TableViewer
. That works pretty well except for selection.
We're having following issue :
- Our
TableViewer
support sorting and filtering. When we use a virtual tableviewer, changing the selection does not preserve the current selected item but the row currently selected.This leads to another item being selected. e.g: If Item 'A' present at the 5th row is selected by user and sorting is performed, then after sorting the Item at the 5th row gets selected instead of the Item 'A'. Using a non virtualTableViewer
, everything works fine.
We tried to go into debug and found out that the cache from the AbstractTableViewer.VirtualManager
class seems to be up to date with the model.
Forcing the cache to be used in the AbstractTableViewer.virtualSetSelectionToWidget()
can be a possible approach.
We have tried to implement a solution suggested in https://bugs.eclipse.org/bugs/show_bug.cgi?id=338696. However it didn't work.
Please suggest some pointers or alternative work around.
Thanks for the answers.
回答1:
As a workaround for working with huge tables I would suggest you to take a look at the Nattable project http://www.eclipse.org/nattable/. It supports everything you need (sorting, filtering, tree structured elements, lazy loading etc.). We successfully use it in our project, where it is necessary to display hundreds of thousands elements as a tree with around 160 columns. It also has some pretty cool styling features, which can make your table more user-friendly and interactive. Hope this helps
来源:https://stackoverflow.com/questions/14957195/virtual-tableviewer-sorting-causes-selection-problems