Closed sebasira closed 4 years ago
Hi! I guess you have found a solution by now, but for future readers:
@JsonValue
on the server side:public enum GenderType{
MALE("boy"), FEMALE("girl");
public final String displayValue;
GenderType(String displayValue) {
this.displayValue = displayValue;
}
@Override
@JsonValue
public String toString() {
return displayValue;
}
}
render
on the client side:const genderMap = {
FEMALE: 'girl',
MALE: 'boy'
}
$('#my-table').DataTable({
columns: [
{
data: 'gender',
render: (data) => genderMap[data] || '-'
},
]
});
Thanks! Yes I solve it by the second approach. But I like most the first one because I don't need to replicate the genderMap
whenever the enum changes.
Thank you!
I have a problem and don't know how to solve it.
There's an Entity, let's call it Person with the following definition
The GenderType is an enum like:
And when rendering the DataTable I have:
And the problem I'm facing is that the GENDER Column displays MALE or FEMALE and I want it to be boy or girl. (It's a little bit complex than that, but the same principle). I mean what I want is to display the String value of the enum.
I've also tried with:
But it gives me this error:
and the DataTable is not rendered.
Thank you!