Reputation: 107
I have a entity of some datasource. It has List of object Pojo. It can be get by ds.getRows(). I'm trying to bind TableView on this list very hard.
tblHlp.itemsProperty().bindBidirectional(new SimpleListProperty<>(FXCollections.observableArrayList(ds.getRows())));
When I change that ObservableList which I created FXCollections.observableArrayList(ds.getRows())) tableView is changed too. But I want to get the same effect when I change List in ds (ds.getRows). Any ideas?
Upvotes: 0
Views: 6531
Reputation: 2211
I don't think you can do it like that.
What you can do is to add a ListChangeListener on the ObservableList you created and then manage manually the items to add/remove in your other list. For example something like that:
ListChangeListener<Object>() {
@Override
public void onChanged(javafx.collections.ListChangeListener.Change<? extends Object> change) {
while (change.next()) {
//If items are removed
for (Objectremitem : change.getRemoved()) {
unfixColumn(remitem);
}
//If items are added
for (Objectadditem : change.getAddedSubList()) {
fixColumn(additem);
}
}
updateHighlightSelection();
}
};
Don't forget to take a look at the Javadoc here : http://download.java.net/jdk8/jfxdocs/javafx/collections/ObservableList.html
And how to use JavaFX collections here : http://docs.oracle.com/javafx/2/collections/jfxpub-collections.htm
Upvotes: 1