Enumeration value in Widget definition XML

1
I'm currently working on a widget that uses the enumeration of an object attribute. I want to match the current value on certain values, that are configured in the modeler. The widget XML allows me to select the attributes with an enumeration, so that is fine. However, if I want to supply enumeration values for this enumeration, it is not possible. Now I just enter the keys as string value, but that does not involve a consistency check on a change of the enumeration itself. Is this possible?
asked
2 answers
1

I don't think this is possible by default. Perhaps you could work around it by using a constraint attribute type. As this will allow you to type in xpath. In Xpath you are able to access the enumeration values.

answered
0

Ther are 2 types of enumerations

1) Mendix entity attribute of the type enumeration.

In your widget you can access the details via the MetaObject

https://apidocs.mendix.com/6/client/mendix_lib_MxMetaObject.html

var mxmetaobject = mx.meta.getEntity("MyFirstModule.Paint");

mxmetaobject.getEnumKVPairs("Color"); // { red: "Red",
                                      //   green: "Green",
                                      //   blue: "Blue" }

or directly through the mx object

https://apidocs.mendix.com/6/client/mendix_lib_MxObject.html

mxobject.getOptions("Color"); // [ "red", "green", "blue" ]

 

2) Widget attributes, options to configure inside your widget.

<property key="colorEnum" type="enumeration" defaultValue="xff0000">
  <caption>Textcolor</caption>
  <category>Appearance</category>
  <description>The textcolor of the message in the widget</description>
  <enumerationValues>
    <enumerationValue key="xff0000">Red</enumerationValue>
    <enumerationValue key="x000000">Black</enumerationValue>
    <enumerationValue key="xffffff">White</enumerationValue>
  </enumerationValues>
</property>

https://docs.mendix.com/refguide6/xml-reference-guide#enumeration

 

answered