Reputation: 11539
I am not looking to disable the sorting of a TableView
when I click on the column header. But I am looking for a programmatic way to rid all column sorting at any time, as shown below in the screenshot in the ID column. I want that sort arrow gone.
The reason I need to remove the sorters at any time is because I have features that move searched records to the top, and sorting will mess this up. But I want to allow the user to sort whenever they want when they aren't using this feature.
I've spent probably 45 minutes digging through the TableView
and TableColumn
API looking for something that will turn it off. Is there a way to do this without binding to a SortedList
? I'd prefer not to mess with the items backing the TableView
, but rather the TableView
or TableColumn
itself.
Upvotes: 3
Views: 1352
Reputation: 11539
Got some help elsewhere from Jonathan Giles. You can remove the sorts by calling the following
tableView.getSortOrder().clear()
Unfortunately, I didn't realize the sorters physically modified the backing ObservableList
of items. So the solution would be to call the above method and re-order items manually that I've deemed to be the "natural order".
Upvotes: 4