Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Unable to retrieve index in model from selection
Unable to retrieve index in model from selection [message #1219013] Fri, 29 November 2013 15:42 Go to next message
Alain Bernard is currently offline Alain BernardFriend
Messages: 15
Registered: November 2013
Junior Member

Hello,

I've implemented a NatTable with GroupBy, Filter and Sorting capabilities. All work greats. But when I register on RowSelectionEvents (with a RowSelectionProvider) I'm unable to retrieve the position of the selection in my underlying model from the selected row index.

Example :
With no filter applied, if I select the row 0, it corresponds to the item 0 in my model.
But if I activate some filter and I select the row 0, the corresponding item in my model is not 0 but, maybe, the item 149.

So I'm trying to convert the position 0 in my selection layer to the correct index in my model.
I've tried :
LayerUtil.convertRowPosition(selectionLayer, rowPosition, bodyDataLayer)

selectionLayer.localToUnderlyingRowPosition(rowPosition)
but it doesn't give me the good result. I think I'm doing something wrong and that someone can give me some piece of solution Smile

Regards,
Alain
Re: Unable to retrieve index in model from selection [message #1219032 is a reply to message #1219013] Fri, 29 November 2013 20:36 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
The reason for this is that you are using GlazedLists. Smile

On filtering, the elements are removed from the FilterList. GlazedLists are perfoming direct transformations in the special lists. As your NatTable is build on top of the FilterList I assume, the index you are getting is the real index for the NatTable, as it is the FilterList index. You could try to get the index by doing a indexOf on a underlying list.
Re: Unable to retrieve index in model from selection [message #1219496 is a reply to message #1219032] Wed, 04 December 2013 09:17 Go to previous message
Alain Bernard is currently offline Alain BernardFriend
Messages: 15
Registered: November 2013
Junior Member

Thank you for your reply. I didn't realize that the NatTable index was the FilterList index.
But in fact, the problem was that the filterList.get(index) returned me the wrong object because I worked on an outdated FilterList: I'm in an Eclipse editor and the model must be refreshed at each time the source file is modified. My update strategy was not a good one for the FilterList and the NatTable therefore worked on an outdated list. I resolved that by refreshing directly the underlying EventList which transmits properly the update to the SortedList and then to the FilterList.
Previous Topic:Info about applied Filter
Next Topic:Reference of row objects
Goto Forum:
  


Current Time: Fri Mar 29 10:49:25 GMT 2024

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

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

Back to the top