Is it possible to have a dynamic style for the options of a reference selector?

0
I have a reference selector and I’d like each option’s class to change dynamically based on one of its attributes. Is there a way to implement that?
asked
2 answers
0

Reference Selector widget currently does not support assigning dynamic CSS classes to individual options based on their attributes.


A recommended workaround is to replace the Reference Selector with a custom selection pattern using a ListView or DataGrid2. You can open a popup page, display the selectable objects in a ListView or DataGrid2, and use the Dynamic class property on the container or row to assign a CSS class based on the object’s attribute.


This approach provides full control over styling and is the most flexible and maintainable solution for implementing attribute-based visual differences between selectable items.

answered
0

hi,


No in standard Mendix Reference Selector, you cannot apply dynamic styling per option.

The dropdown options are rendered internally and Mendix does not expose a property to assign classes conditionally to each item.

Why

Reference Selector:

  • Renders options using internal widget logic
  • Does not support conditional classes per row
  • Only supports styling at the widget level, not option level

Correct & Supported Solutions

Option 1 (Recommended)

Use a Custom Selector Page:

  1. Replace Reference Selector with a button
  2. Open a Select Page
  3. Use a List View or DataGrid2
  4. Apply Conditional Class on each row:

Based on attribute
  1. On click → Set reference manually

This gives full styling control.

Option 2 (If using Data Widgets)

Use Combo Box (Data Widgets module)

But even here, dynamic styling per option is limited and not fully supported.

What Will NOT Work

  • SCSS targeting individual dropdown items
  • Enum class styling
  • Atlas overrides

Dropdown options are rendered dynamically and not easily styleable.

If you need dynamic styling per option, do not use Reference Selector.

Use a custom selection page with List View/DataGrid and conditional classes.

That is the clean and scalable solution.


answered