Multi select in drop down

0
Here i am using “BOOT STRAP MULTI SELECT ” widget to have multi select in drop down but while configuring it  i need to have m-m, or 1-1 association for an data source entity, But the thing here  is am having  one entity as non-persistable and other entity as persistable, so that  i am unable to make m-m asssociation and give data source as required. Can any one help me here how to over come this..??   Thanks in advance ..!!
asked
1 answers
1

Hey Mohsin,

This is a limitation in the current set of options available in Mendix. The solution is fairly simple:

  1. Add a listview of the item you want to select $Select, within a dataview of the item you want to associate with $Known.
  2. Add two attributes to $Known: 1 a string called /SelectedString and another boolean called /SelectListIsOpen
  3. Wrap this listview in a container, and make it conditionally visible based on the attribute /SelectListIsOpen
  4. Create a toggle Nanoflow that sets the inverse value of /SelectIsOpen, make sure the user has all necessary access rights (read/write)  
  5. Add an on-click behaviour to the listItem (or e.g. a container in the list item): make sure to set /SelectIsOpen to false, make sure to set /SelectedString to the key string value of the item you just clicked on. Furthermore, set the proper association between $Select and $Known.
  6. The only thing you need to do now is to add a text field with the $Known/SelectIsOpen, and wrap it in a container; add on-click action using the toggle in item 4.
  7. Make sure to style everything in the same way as a dropdown, so that the user cannot see a difference.
  8. Optionally: add an overlay container (width: 100vw; height: 100vh; position: absolute; top: 0;, right: 0; opacity: 0.5; z-index: 10) that is conditionally visible when /SelectIsOpen. Add on-click action (the toggle from step 4). Make sure that your listview wrapper (step 3) has a higher z-index.

 

This will give you the same behaviour as any dropdown. 

 

Hope this helps – if it does, please mark as correct.

Best regards,

Wouter

answered