Javafx: Re-sorting a column in a TableView

前端 未结 8 1767
春和景丽
春和景丽 2020-12-09 05:22

I have a TableView associated to a TreeView. Each time a node in the TreeView is selected, the TableView is refreshed with different data.

I am able to sort any col

8条回答
  •  攒了一身酷
    2020-12-09 05:35

    I had the same problem and found out that after an update of the data you only have to call the function sort() on the table view:

    TableView rooms;
    ...
    // Update data of rooms
    ...
    rooms.sort()
    

    The table view knows the columns for sorting thus the sort function will sort the new data in the wanted order. This function is only available in Java 8.

提交回复
热议问题