I have a javafx TableView
and I want custom controls inside the columns. Say I want a TextField
in column1
and ComboBox
in column2
and DatePicker
in column3
.
I know that I should create a class that extends TableCell
and override the updateItem()
method....
But I read that specifically for this purpose we have default classes like ComboBoxTableCell
, TextFieldTableCell
etc in the cell package and it is recommended to use them. So I'm able to achieve this with the below code.
loadingStatusTableColumn.setCellFactory(ComboBoxTableCell.forTableColumn("Off", "Load All", "Load By Time"));
startTimeTableColumn.setCellFactory(TextFieldTableCell.forTableColumn(null));
stopTimeTableColumn.setCellFactory(TextFieldTableCell.forTableColumn(null));
Now my requirement is when I select some value from the loadingStatusTableColumn
combobox (Say "Off"
), I want to disable the next 2 columns startTimeTableColumn
, stopTimeTableColumn
and they should be enable when I select any value other than "Off"
in the loadingStatusTableColumn
column.
How to achieve this with my above code(without creating TableCell subclass).
Can i achieve the below line effect through FXML?
loadingStatusTableColumn.setCellFactory(ComboBoxTableCell.forTableColumn("Off", "Load All", "Load By Time"));
<cellFactory><MyCellFactory /></cellValueFactory>
I know the above works because it is a custom class I have, but can I do the below?
<cellFactory><ComboBoxTableCell /></cellValueFactory>
Thanks in Advance!