我有这个常见问题,看起来确实如此。重置后,我的表格 View 不会刷新我的项目。我检查了数据,它是新的。
我从网上尝试了多种解决方案,但都没有成功。
无法重置所有列,因为它会增加一空一额外(不知道为什么)并且调整大小会中断。
我的表格不可可编辑。新数据已更改。
如果我更改项目的顺序并且行更改 (:|),则会刷新数据。
我只是没有想法。
目前刷新代码非常简单。
ObservableList<User> data = FXCollections.observableArrayList(User.getResellers());
reseller_table.setItems(data);
再一次,新数据是正确的。当我对 tableView 进行选择时,它会返回新的正确项目。
最佳答案
由于 JavaFX 8u60
你可以使用(假设 tableView
是 TableView 类的一个实例):
tableView.refresh();
来自文档:
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.
关于JavaFX 2.1 TableView 刷新项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11065140/