JDK-8126462 : Sorting the table view changes the existing selection
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: fx2.1,7u6
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2012-05-13
  • Updated: 2015-06-17
  • Resolved: 2013-07-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Relates :  
Relates :  
Description
If a row is selected in the table view, sorting by any column changes the selection; the selected index usually remains the same so whatever object is at that index based on the new sort order becomes the selected object.
Is it a bug or a feature? If it is a feature is there an easy way to maintain the existing selection after the sort?
With the TableViewSample inJavaFX examples I have seen that if I keep on sorting for a few times with different columns, even the index changes in some cases, that is definitely a bug.

Comments
This is still an issue in 8.0 using SortedList and binding the Comparator as described in the TableView docs. See RT-36352.
28-03-2014

Unless there is a customer request, I would rather not backport due to the potential for regressions.
01-08-2013

Is this issue a backport candidate?
01-08-2013

Resolved as RT-30156 for JavaFX 8.0, so closing this as a duplicate.
31-07-2013

Sorting change the selected row index to -1. But focus stay on selected row. (2.2.4 & 8ea_b71). I forced this by tableView.getItems().addListener(new ListChangeListener<Profile>() { @Override public void onChanged( javafx.collections.ListChangeListener.Change<? extends Profile> arg0) { tableView.getSelectionModel().clearSelection(); } });
17-01-2013

It's definitely a bug. The selected item should remain the same after sort.
11-06-2012

Yes, I have the same issue. If there was a way to "resort" the selected column, even manually, we could live with it. But it is definitely worth to fix. In my case, the TableView is associated with a TreeView and is constantly changing when something in the tree is selected.
23-05-2012