A way to populate some sort of list box, drop down, or menu with list of attribute values from an entity?

Hi, I am new to Mendix and I am struggling with displaying data in some sort of drop down menu form.  My app is using an external SQL database.  I have created entities that match the returns of two stored procedures in the DB, and have been able to successfully run the stored procedures and view their returns in a list view on my home page, so I know I am connected and my data is coming in correctly.  Below is a screen shot of the entities I have created: What I need to do is display a list of the plant names in some sort of drop down menu or collapsible list box.  I will also need to do the same for area.  In our current solution we use the Plant and Area values as global filters, so they must be specified before we run queries to populate any grids.  Is there a simple way to get these values to display in this way?  Also, is there a way to create an association between these two entities even though their data comes from an external source (there are tow Foreign Keys in the Area entity that tie it to the Plant entity)?  So far, I have tried to use both the drop down and reference selector widgets.  With the drop down, I tried to find a way to get my SQL return from list form into an enumeration, and I was unsuccessful.  I have also tried creating various associations and using a reference selector without success.  I would appreciate any help you can offer. Thank you Kathleen
1 answers


I’ll tackle one part of your question first: 

  • to create an association between your tables, you would draw that association in the domain model (seems like you’ve done that while learning).  If I understand your tables correctly, each pltPlant object can be associated with one pltArea, meaning each pltArea can have multiple pltPlants.  If that’s correct, drag an arrow from pltPlant to pltArea and the association should be created correctly.
  • to populate the association, you’ll need a microflow that will be run after you import the data from the external system.  This microflow will
    • retrieve all pltPlant objects (using an XPath retrieve
    • loop through these objects with the microflow Loop tool
    • for each pltPlant, retrieve the first pltArea where PKpltPlant = pltPlant.PKpltPlant (you’ll need to use an XPath retrieve for this)
    • set the association of pltPlant to the retrieved object
  • once you’ve accomplished that, you can use one of the native tools in Mendix to get a drop down like you described.
    • create a page in Mendix
    • on this page, place a Datagrid
    • point the source of the Datagrid to pltPlant
    • when prompted, let Mendix automatically populate the grid
    • in the Search section of the datagrid, add a new drop down search field and point it to the associated pltArea entity (I guess maybe the Area attribute)

Now when you start your app, you can import data, run the microflow you created and navigate to the page you created to see a drop down in the search bar of the Datagrid.

Hope that helps you get started,


P.S. it will probably make things easier to set both entities to be persistable.