Simple toggle (show/hide) inside an existing dataview
I have two ui cards A and B. B by default will be hidden where as A has the option to “edit”, when this option is selected, card A will be hidden then card B will show instead. This is just a simple show hide when you click a button (“Edit”). These cards sit with in a dataview which already have a datasource attached. One of the issues I am facing is that I don’t know how to achieve this in mendix. I have a microflow for the edit button which is going to create a variable change it accordingly so that it has the correct true or false value and returns that at the end. When I click this button and microflow is run, I cannot access that returned value to use and hide the cards respectively using the visibility option. Based on attribute – no attribute available. Based on expression – cannot use the returned varaible from the microflow here? Why? What is the best way of achieving this? Is this even possible to achieve
Mathew P A
Within visible conditions you can only use the attributes of the (nested) dataview dat the card is in. So if you want to use that boolean from the microflow you created, you should put the card inside a dataview which holds the object that contains that boolean attribute. If the dataview of card B has a static datasource already, you can put that dataview inside another dataview that contains the boolean attribute, then you can access the attribute from visible conditions.
You’d typically accomplish this by using a “helper” entity.
Create a non-persistent entity in your domain model with an attribute to use for tracking the state of the 2 cards. A boolean would work. Let’s call it “Editable”. Default it to false.
On your page, add a data view and source it from a microflow. The microflow should create one of these helper entities and return it.
Put the cards inside that data view
The “switch” nanoflow will toggle the “Editable” attribute by setting it to not($MyHelper/Editable). Or create 2 nanoflows to switch the boolean to true or false
Set conditional visibility of your cards based on the Editable attribute