当我将列动态添加到TableView时,面临编辑它们的问题。数据是从数据库动态加载的,因此我需要像下面这样完全设置单元格参数:
for (String columnName : Operator.getColumnNames()) {//An array names of columns from database
TableColumn column = new TableColumn(columnName);
column.setCellFactory(TextFieldTableCell.forTableColumn());
column.setCellValueFactory(new Callback<CellDataFeatures<ObservableList,String>,ObservableValue<String>>(){
public ObservableValue<String> call(CellDataFeatures<ObservableList, String> param) {
return new SimpleStringProperty(param.getValue().get(Operator.getColumnNames().indexOf(columnName)).toString());
}
});
column.setOnEditCommit(e -> {
...
});
}
Look at that too (instance e methods)...
例如,如果她不是通用的,如何设置 setOnEditCommit 列方法并更改内容...
谢谢!