DataGrid editing generated column

So I have a DataGrid that displays comments on an object, stored as a String, but only when certain conditions are met, so the column that displays the comments is generated like this:


DataGrid.Column commentColumn = wellsGrid.addGeneratedColumn("wellComment", new DataGrid.ColumnGenerator<Well, String>() {
    @Override
    public String getValue(DataGrid.ColumnGeneratorEvent<Well> event) {
        return event.getItem().getWComment();
    }

    @Override
    public Class<String> getType() {
        return String.class;
    }
});
commentColumn.setCaption("Comment");

However, I was unable to edit the column, even when explicitly calling setEditable(true), so I thought maybe a field generator would work, so I applied this to the column:


commentColumn.setEditorFieldGenerator((datasource, property) -> {
    TextField textField = componentsFactory.createComponent(TextField.class);
    textField.setDatasource(datasource,property);
    return textField;
});

but that didn’t work either. Am I doing something massively wrong?

Thank you for your time.

I realize now that this is a stupid question. Why do this when I can just have the column always included in the DataGrid and just disable it when needed, rather than having all of this unnecessary generation? At least this is up now for people who make the same mistake as me.

Hi,

The generated columns are read-only and cannot be edited by design. The read-only entity fields also cannot be edited.

Regards,
Gleb