I have this common issue, as it appears to be. My table view wont refresh my items after I reset them. I have checked the data and it's the new one.
I tried multiple solution from internet but no success.
Can't reset all the columns because it adds one empty one extra (dont know why) and the resize just breakes.
My table is not editable. The new data is changed.
The data is refreshed if I change the ordering of the items and the rows change (:|).
I'm just left without ideas.
At the moment the refresh code is pretty simple.
ObservableList<User> data = FXCollections.observableArrayList(User.getResellers()); reseller_table.setItems(data);
Again the new data is correct. When I make an selection to the tableView it returns the new correct Item.
Since JavaFX 8u60 you can use(assuming tableView is an instance of TableView class): tableView. refresh();
The JavaFX scene can be forcibly refreshed by changing the width or height of the Scene by a fractional number of pixels (for example, 0.001). This change forces the background windowing and rendering services to recalculate layout and rendering requirements for the scene graph.
The TableView class provides built-in capabilities to sort data in columns. Users can alter the order of data by clicking column headers. The first click enables the ascending sorting order, the second click enables descending sorting order, and the third click disables sorting. By default, no sorting is applied.
Workaround:
tableView.getColumns().get(0).setVisible(false); tableView.getColumns().get(0).setVisible(true);
Since JavaFX 8u60
you can use(assuming tableView
is an instance of TableView class):
tableView.refresh();
From the documentation:
Calling refresh() forces the TableView control to recreate and repopulate the cells necessary to populate the visual bounds of the control. In other words, this forces the TableView to update what it is showing to the user. This is useful in cases where the underlying data source has changed in a way that is not observed by the TableView itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With