Hi Man
My Bad inside a Mendix Custom Widget, you cannot directly read the caption of an enumeration entry at runtime.Mendix does NOT expose enumeration captions to JavaScript after mendix 9+, But I can give somework around which is easy by manually map Enumeration Values to Captions (Hardcoded in Widget).
Step 1 — Create a static map inside widget source.
Step 2 — Get current name of enumeration from EditableValue
const current = props.enumAttribute.value; // "New" / "Approved" / "Rejected"
const caption = StatusEnumMap[current];
This works only if captions don’t need localization and rarely change.
I had tested this is working as expected but the only problem is it is harcoded.But instead of hardcode you can use json also.
If it doesnt help let me know I can help you out!!
Hi,
I am working on a solution to use the full power of enumerations. Code is ready but I still have to write documentation. It is part of my Mendix collection called ConventCommons.
You can have a sneak preview on https://github.com/LuchKlooster/ConventCommons.
I hope you can figure out how to implement it. It's pretty self explaining.
Sorry Su Tong,
Forgot to set the repro to public.
I added a shorthand implementation guide in github readme.
To everybody: You can have a sneak preview on https://github.com/LuchKlooster/ConventCommons.