This is a follow up question based on TreeView in a table cell Java FX 8
I am having a table in which a particular column has to popup a treeview on click.
I am defining the table column's cellfactory as follows
col4.setCellFactory(new Callback<TableColumn<User,DepartmentTree>, TableCell<User,DepartmentTree>>() {
@Override
public TableCell<User, DepartmentTree> call(
TableColumn<User,DepartmentTree> param)
{
TableCell<User, DepartmentTree> deptCombo = new TableCell<User,DepartmentTree>()
{
@Override
public void startEdit()
{
setGraphic(testtree);
}
@Override
public void cancelEdit()
{
setGraphic(null);
setText("");
}
@Override
public void updateItem(DepartmentTree item, boolean empty)
{
super.updateItem(item, empty);
setText(item.nameProperty().get());
}
};
return deptCombo;
}
});
This is resulting in the treeview appearing inside the cell as per the first image. However I would like the treeview to popout of the cell like the second image (the second image is an incorrect implementation using the treeview inside a combobox)
Does the popout appear by mere styling or do I have to modify any code?
Any guidance will be helpful.
I have created my own class of TreeViewPopupTableCell to do this. Basically what you get is, when a table cell is left clicked (first click will choose the row,second will choose the cell) you get a popup with a treeview loaded in it.
To use this cell, in your tableview set the cellfactory as follows.