Reputation: 215
here's my interesting situation,
I am trying to access a Combobox from a Tableview which has a column containing a cellfactory of ComboBoxTableCell. This will be accessed through an event handler such that when a user hits 'enter' on the row, the combobox will show its items.
The ComboboxTableCell was created as
tableViewCol.setCellFactory(ComboBoxTableCell.forTableColumn(anObservableArrayList));
The tableview which I could access is referenced as:
@FXML
private TableView<Obj> tableView;
@FXML
private TableColumn<Obj, String> tableViewCol;
The furthest I was able to get was the tablecol following these paths whose .getClass() resulted with: "class javafx.scene.control.TableColumn$1":
tableView.getSelectionModel().getSelectedCells().get(0).getTableColumn().getCellFactory().call()
tableView.getSelectionModel().getSelectedCells().get(0).getTableColumn().cellFactoryProperty()
Once again, I'm trying to access a selected row in a tableview whose column has a ComboBoxTableCell and I'm trying to have the selected row's comboBox open when an event click, enter happens. I just can't map out how to access it and it's driving me nuts.
For visual rep see first link then second. https://i.sstatic.net/teV4S.png https://i.sstatic.net/7kjPs.png (Bleh, newbies can't post images).
Any help suggestions, alternatives, feedback are helpful. Thanks!
Upvotes: 2
Views: 900
Reputation: 1768
You can access the Comobobx over cell.getGraphic().
But do something like this:
tableView.edit(tableView.getSelectionModel().getSelectedIndex(), tableViewCol);
and this everytime the Selection changed.
If you want you can write your own Comboboxcell with automatic shows its Graphic when its row is selected.
Upvotes: 0