guys,
my Program has a lot of TableViews. In all tables except one sorting is working. I can't find my mistake in that single TableViews. When clicking the header it seems like its sorting but not refreshing the view. If I change the tab and go back, the TableView is sorted. If a row is selected and I click on the header the selected color is sorted on the right spot but not the table data.
I have my ObservableList and TableView:
private ObservableList<ProjectViewModel> projectViewModelList = null;
// some more TableColumns
@FXML
TableColumn<ProjectViewModel, String> TableColumnToolchainStepphase;
@FXML
TableView<ProjectViewModel> TableViewToolchain;
my initialize:
@FXML
public void initialize(){
//...
initializeLists();
//...
initTableViewToolchain();
initTableColumns();
//...
}
private void initializeLists(){
projectViewModelList = FXCollections.observableArrayList();
}
private void initTableViewToolchain(){
TableViewToolchain.setItems( projectViewModelList );
}
private void initTableColumns(){
TableColumnToolchainStepphase
.setCellValueFactory( new Callback<CellDataFeatures<ProjectViewModel, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call( CellDataFeatures<ProjectViewModel, String> param ){
String string = param.getValue().getStepphaseString();
return new ReadOnlyStringWrapper( string );
}
} );
}
my table population:
private void setProjectViewModelList( Collection<ProjectViewModel> projectViewModelCollection ){
projectViewModelList.clear();
projectViewModelList.setAll( projectViewModelCollection );
}
Where did i go wrong?
I did a workaround i force the sort and refresh on mouseclick:
TableViewToolchain.setOnMouseClicked( ( MouseEvent event ) ->{
TableViewToolchain.sort();
TableViewToolchain.refresh();
} );
So when clicking on those coulmns the sort happens as intended.