I am having a problem trying to figure out how to make a TableView
show the correct data based on each entry response status. I thought FilteredList
A FilteredList
will update whenever it's Predicate
changes or whenever it detects a change in the source ObservableList
. The type of event you want to fire is an update event. This event signifies one or more elements have been updated (e.g. when a property changes). In order to do this you have to construct the ObservableList
with the appropriate factory method: FXCollections.observableArrayList(Callback).
This factory method takes a Callback that accepts an element of the ObservableList
and returns an Observable[]
. The Observable
s in the array will be listened to for invalidation events and, when detected, will cause the ObservableList
to fire an update change.
From looking at your code it seems1 like the Model
class has a status
property. If you want to fire updates when the status
changes you should use:
ObservableList<Model> masterData = FXCollections.observableArrayList<>(model ->
new Observable[]{model.statusProperty()});
You can add more Observable
s to the array if you wish for updates to be fired for more than just changes to the status
property.
Now when the status
property changes the FilteredList
will notice and filter the element(s) if needed.
1. You hadn't posted the Model
class when I wrote this answer. However, I manage to "reverse engineer" it from the available code and tested it using the Callback
extractor. The elements were removed from the FilteredList
, and thus the TableView
, when the status
changed from PENDING to whatever the new status ended up being.