I am trying to create an table which contains an column with one header but has several entries per row in JavaFX 8. The result should look more or less like this:
I tried to add subcolumns which works perfectly, but i was not able to hide the headers of the subcolums. I found solutions to hide the header only for older versions of javafx and for ListView.
Also i tried to add an whole ListView for one row, similar to what is suggested by jewelsea here: JavaFX table- how to add components?
Of course I used a ListView instead of a Button. But then the TableView only presents the first entry of the ListView. Here my code for the Callback class:
public class IeListViewCallback implements
Callback<TableColumn<ConnectedIEList, ConnectedIEList>, TableCell<ConnectedIEList, ConnectedIEList>> {
@Override
public TableCell<ConnectedIEList, ConnectedIEList> call(TableColumn<ConnectedIEList, ConnectedIEList> param) {
return new TableCell<ConnectedIEList, ConnectedIEList>() {
final ListView<String> listView = new ListView<String>();
{
listView.getItems().add("entry 1");
listView.getItems().add("entry 2");
listView.getItems().add("entry 3");
}
@Override
public void updateItem(final ConnectedIEList connectedIEList, boolean empty) {
super.updateItem(connectedIEList, empty);
setGraphic(listView);
}
};
}
}
Of course this code was only for testing. Usually the entries would depend on the commited List instead of being hard coded!