2017-07-31 92 views
0

在排序列後嘗試預覽行時出現問題。按列排序後,JTable模型不會刷新

例如: 這是我的表格排序前

enter image description here

當我嘗試第二列進行排序,我得到這樣的結果是正常的:

enter image description here

但是當我嘗試預覽ID(A199)的第二行的細節時,我得到了之前排序前的第二行的(A195)。 (我雙擊一排排預覽細節時已經添加了一個動作)

,所以我的假設是,該表的模型不能正確更新,這是我已經試過:

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); 

任何幫助,將不勝感激 !

回答

1

作爲the doc saysTableRowSorter只關心視圖而不關心表的模型。

在使用排序/過濾功能(如您的情況)的情況下,某些功能用於在文檔的描述中轉換模型和視圖之間的索引。

嘗試更改ActionListener以使用這些功能,並且應該修復問題。

+0

Thx Bracco的提示我會試試:) – Anna