I have a single-select radiobuttongroup with a boolean field behind it in the DataClass.
I don’t want to display “true” / “false” as options for the user, but custom Strings, let’s say “red option” for true and “green option” for false.
I see in the API that there is a function called setRenderer, but I am not sure how to use it.
I already figured out how to do it in a grid, but not on the selection box…
Selection box:
rbgroup = new RadioButtonGroup<>();
rbgroup.setRequired(true);
rbgroup.setLabel("Title of radiobuttongroup");
rbgroup.setItems(true, false); // how to display them in the frontend as "Green option" / "Red option"?
....
binder.forField(gbgroup).bind("mybooleanField");
Grid:
addColumn((mn) -> { // custom display
final String displayAS;
if (mn.getBoolValue()) {
displayAS = "Option Red";
} else {
displayAS = "Option Green";
}
return displayAS;
})
.setHeader("Columntitle")
.setFlexGrow(1)
.setSortable(true)
.setKey("Color Option");