Currently when defining a property of type “attribute” in the XML there is no way to find out in the widgetname.editorConfig.ts what the type of that property is.
For example:
<property key="attribute" type="attribute" required="true">
<caption>Attribute</caption>
<description/>
<attributeTypes>
<attributeType name="String"/>
<attributeType name="Decimal"/>
<attributeType name="Integer"/>
</attributeTypes>
</property>
Will translate to the following typings/WidgetNameProps.d.ts:
attribute: EditableValue<string | Big>;
While in WidgetName.editorConfig.ts there is no way to retrieve the type of “attribute”.
Currently the Core Mendix TextBox does have a visibility toggle based on if the attribute type is a decimal or not & the typings generated based on the xml definition also uses the attributetype.
It would be great if the attribute type is also passed along so that we can use it in the WidgetName.EditorConfig.ts & other places!
Issue: Cannot Access Attribute Type in editorConfig.ts
for Pluggable Widgets
When defining an <attribute>
property in the widget XML, you can specify allowed types using <attributeTypes>
, such as String, Decimal, Integer.
This generates a union type in WidgetNameProps.d.ts
, like EditableValue<string | Big>
, which is usable in the React component.
However, in WidgetName.editorConfig.ts
, the actual selected attribute type is not accessible, so you cannot dynamically toggle other properties based on it.
Core Mendix widgets (like TextBox) can conditionally show properties based on attribute type, but this behavior is not currently available for custom widgets.
Mendix does not expose the selected attributeType
in editor config APIs, which is a known limitation.
The only place you can check the attribute type is at runtime inside the React component, using props.attribute?.type
.
There is no official workaround in editorConfig.ts
today; developers use extra toggles or enum workarounds to simulate type-based conditions.
A feature request or improvement is needed from Mendix to expose this type information during the Studio Pro config phase.
Reference Links
Mendix Forum Question (related):https://community.mendix.com/link/space/widgets/questions/138357
Mendix Widget XML Specification:https://docs.mendix.com/apidocs-mxsdk/apidocs/pluggable-widgets-property-types/
Mendix Widget SDK:https://docs.mendix.com/howto/extensibility/create-a-pluggable-widget/
I was developing a Combobox widget customization and the task was to handle certain entities differently: add a CSS class when the selected value differs from the original. To my surprise, the pluggable widget api conceals this important information:
Basically, only the list datasource items expose the GUID now and there's chance that it will be replaced with a bogus string too.
In the end we had to consider the first rendered value the original even though it's not always the case.