Doubts related to gallery

0
I am using a button in the gallery view. This button is getting displayed 5 times with different names based on id and I've configured it as well. Now i want to display 5 different icons. Is it really possible for me to display it?
asked
2 answers
0

Yes, it is possible, but not with one standard Button widget alone if you want the icon itself to change dynamically per gallery item.


In a Gallery, each row is rendered from the same template. So if you configure one Button with one icon, that same icon is reused for every item. The caption can come from data, but the icon property is not dynamically data-driven in the standard setup.


The usual Mendix way is:

  • place 5 buttons or 5 image/icon widgets
  • give each one a different icon
  • use conditional visibility based on your id or type attribute


That is the simplest and most maintainable approach.


If you really want to keep a single clickable element, another option is to show an Image dynamically from data and place it inside a container that acts like a button. But for normal Mendix pages, conditional visibility with multiple icons/buttons is usually the cleanest solution.


So in short:

Different captions from data = easy

Different icons from data = not directly supported on one standard button

Best practice = use multiple widgets with conditional visibility


If this resolves your issue, you can mark it as accepted.

answered
0

Hi,


Yes, it is possible to display different icons for each item inside a Gallery. Since a Gallery repeats UI based on each object, the correct approach is to make the icon dynamic based on the object’s data.

Dynamic Icon using Attribute

    • Add an attribute in your entityExample: IconType (String or Enumeration)
    • Set value for each recordBased on your logic (ID or name), assign values like:
      • "edit"
      • "delete"
      • "view"
      • "download"
      • "share"
  1. Use Dynamic Class or Conditional Visibility

Option A: Using Dynamic Class (best for flexibility)

  • Select the button inside the Gallery
  • Go to Appearance → Class
  • Add a dynamic class like:
if $currentObject/IconType = 'edit' then 'fa fa-edit'
else if $currentObject/IconType = 'delete' then 'fa fa-trash'
else if $currentObject/IconType = 'view' then 'fa fa-eye'
else ''

Make sure you are using a supported icon library (Atlas UI uses Font Awesome).

Option B: Using Multiple Icons with Conditional Visibility

  1. Place multiple icon widgets inside the button (one for each icon)
  2. For each icon:
    • Set Visible = true only when condition matches

Example:

  • Edit icon → visible when $currentObject/IconType = 'edit'
  • Delete icon → visible when $currentObject/IconType = 'delete'

  • Gallery always works per object ($currentObject), so your logic must depend on object data
  • Do not try to hardcode per position (like 1st item, 2nd item). Always use attributes
  • Dynamic class approach is cleaner and more scalable


  • Yes, it is fully possible
  • Use an attribute (String/Enum) to control icon per item
  • Apply:
    • Dynamic class (recommended), or
    • Conditional visibility



answered