Reputation: 119
I have a TableView in my application used in standard way with CellValueFactory and ObservableList.
However this is not quite enough for me, I explain why: First column a want to have fixed values that stay forever. Three columns follow filled from class
public class ValuesTriplet {
private StringProperty L1 = new SimpleStringProperty();
private StringProperty L2 = new SimpleStringProperty();
private StringProperty L3 = new SimpleStringProperty();
...
// constructor
// properties setters/getters
}
(This middle part I have working.)
One (last) String column follows.
My problem is that I am reading data from device in following way:
1) the triplets are read and filled to table (the working part) - this also determines rows number
2) single values to last column are read - but only some of rows have them (!). How can I write to existing table without an add() method?
3) goto 1
Or can I have for example single cell factory for every part of these?
In case anything is not clear please ask. Thank you.
Upvotes: 0
Views: 107
Reputation: 160
A little stand alone test case may make it easier for us to understand your problem.
Is this simply a view update problem? And are the properties that fail to update derived from Observable and part of the observable list and registered as columns via a PropertyValueFactory? If not then the TableView won't know automatically that your model changed. You can force an update explicitly this way:
public void updateData() {
if (tableView.getColumns().size()==0)
return;
tableView.getColumns().get(0).setVisible(false);
tableView.getColumns().get(0).setVisible(true);
}
I had this issue in a javafx migration for which I had to use the swing table model with a JavaFx table view. Of course the view is not automatically notified about changes to the model. Calling above code after an update to the model updates the table for me.
Upvotes: 0