Reputation: 1627
I have a problem when trying to preview a row after sorting a column.
for example : this is my table before sorting it
when i try to sort by the second column, i get this result which is normal:
but when i try to preview details of the second line with the ID (A199) i get the ones of (A195) which it was previously the second line before the sort. (i've added an action when doubleclicking a row to preview row details )
so my hypothesis is that the table model is not updated properly, this is what i've tried :
TableRowSorter<PersonneMoraleSearchTableModel> sorter = new TableRowSorter<PersonneMoraleSearchTableModel>(model);
jTable.setRowSorter(sorter);
List<RowSorter.SortKey> sortKeys = new ArrayList<SortKey>(25);
sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING));
sorter.setSortKeys(sortKeys);
sorter.setSortsOnUpdates(true);
any help would be appreciated !
Upvotes: 1
Views: 746
Reputation: 2211
As the doc says TableRowSorter
only cares about the view and not the model of the table.
Some function are used in the description of the doc to convert the indexes between model and view in case a sorting/filtering function (as in your case) is used.
Try changing the ActionListener
to use those function and the problem should be fixed.
Upvotes: 2