将TableColumn定义为TableColumn<Target, String> tableColumnLocation;,并按如下方式填充:
tableColumnLocation.setCellValueFactory(new
PropertyValueFactory<Target, String>("name"));
tableColumnLocation.setCellFactory(ComboBoxTableCell.forTableColumn(locationValues));其中locationValues是从数据库中读取的一组字符串。我试图禁用tableColumnLocation下拉列表,以防另一个复选框列被取消选中。所以问题是如何禁用ComboBoxTableCell。如有任何建议,将不胜感激。
已经能够禁用如下所示的其他TableColumn,但不确定如何继续执行此操作。
tableColumnQty.setCellFactory(
new Callback<TableColumn<Test, String>, TableCell<Test, String>>() {
@Override
public TableCell<Test, String> call(TableColumn<Test, String> paramTableColumn) {
return new TextFieldTableCell<Test, String>(new DefaultStringConverter()) {
@Override
public void updateItem(String s, boolean b) {
super.updateItem(s, b);
if(!isEmpty()) {
Test item = getTableView().getItems().get(getIndex());
if (item.getTarget().equalsIgnoreCase("0")) {
setDisable(true);
setEditable(false);
this.setStyle("-fx-background-color: lightgrey");
} else {
setDisable(false);
setEditable(true);
//if(s != null && !s.equalsIgnoreCase(""))
setStyle("");
}
}
}
};
}
});发布于 2018-03-13 22:40:24
这里是你所需要的:
tableColumnLocation.setCellFactory(
new Callback<TableColumn<Target, String>, TableCell<Target, String>>() {
@Override
public TableCell<Target, String> call(TableColumn<Target, String> paramTableColumn) {
return new ComboBoxTableCell<Target, String>(new DefaultStringConverter(), locationValues) {
@Override
public void updateItem(String s, boolean b) {
super.updateItem(s, b);
if(!isEmpty()) {
Target item = getTableView().getItems().get(getIndex());
if (check if checkbox is unselected) {
setDisable(true);
setEditable(false);
this.setStyle("-fx-background-color: lightgrey");
} else {
setDisable(false);
setEditable(true);
setStyle("");
}
}
}
};
}
});https://stackoverflow.com/questions/49217524
复制相似问题