Conditional Visibility (based on association)

2
I noticed there was some discussion regarding conditional visibility based on attributes derived via association (https://community.mendix.com/link/ideas/16) 2 years ago – while I understand the performance issue, limiting visibility to attributes in the immediate %current object% has a lot of implications for the app I’m working on.   – Has anything changed since then?  - Is the only workaround propagating the associated attributes to each entity that needs conditional visibility (based on assoications)?  
asked
2 answers
3

Hi,

  I can confirm that in Mendix 7.23.5 all you are able to do is check if an association is empty or not. You are not able to make conditionally visible statements based on attributes on the associated entity. If you want to do that, the platform would need to make a retrieve to get the data, so you could replicate that by putting a data view on the page, retrieving the associated object, and then putting the fields you want conditionally visible within that data view. Due to the retrieves, it’s not the most performant solution. I don’t know your exact use case, but if front end performance is paramount, I’d recommend trying to keep the amount of retrieves required to render the page as low as possible. It may means having a non-persistent helper entity or propagating some attributes to the page object.

answered
1

You can make this work by creating a calculated attribute on the associated entity – this effectively propagates the original attribute, but without the maintenance issues. So example:

parent entity

- flag a

child entity

- calculated flag a

Visibility of tabs and other elements in data views based on the child entity can then use the calculated flag a. A performance nightmare to be sure, but it works!

answered