How to do Conditional rendering on Mendix?

0
Scenario is I am using accordion which have all the list of Properties. And inside that widget I am using Units (which has asocciation with Properties: i.e one to many from Property to Units). I can listen to the data changed through accordion. But I am not able to listen throught the list view of units. Also I want to show contents on the right side of my page conditionally i.e if user clicks propery accordion he sees property details and if he clicks units he sees Unit details. Please help me solve this problem.  
asked
1 answers
0

Hi,

To achieve the functionality of showing Property details when clicking on the Property accordion and showing Unit details when clicking on the Units accordion in Mendix, follow these steps

  • Accordion Setup:

    • Create an accordion widget on the page.
    • Configure the accordion to display a list of Properties.
  • Data View for Property Details:

    • Inside the Property accordion pane, add a data view widget.
    • Set the data source of the data view to be the selected Property entity from the accordion's data view.
  • List View for Units:

    • Inside the Units accordion pane, add a list view widget.
    • Configure the list view to display the associated Units for the selected Property using the one-to-many association between Property and Units.
    • Add an "On Click" microflow action for the list view to set a context variable (e.g., selectedUnit) to the clicked Unit entity.
  • Data View for Unit Details:

    • Inside the Units accordion pane, add another data view widget.
    • Set the data source of the data view to be the selectedUnit context variable.
  • Conditional Display:

    • Set the visibility property of the property detail data view to not $selectedUnit.
    • Set the visibility property of the unit detail data view to $selectedUnit.
  • Handle Accordion Clicks:

    • In the "On Click" microflow action for the accordion, set the selectedUnit context variable to null to hide any previously selected unit details.
  • Refresh the Page:

    • In the "On Click" microflow action for the list view of Units, refresh the page to update the visibility of the data views based on the selected unit.
answered