Skip to main content



      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 10:42 Go to next message
Eclipse UserFriend
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 15:36 Go to previous messageGo to next message
Eclipse UserFriend
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 04:17 Go to previous message
Eclipse UserFriend
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: Tue Jul 22 20:44:23 EDT 2025

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

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

Back to the top