Conditional/ Dynamic Filtering

0
Hello,    I want to create a datagrid with 2 or 3 drop downs. I want to be able to select a value from dropdown 1, which would then automatically filter the values available in dropdown 2 and 3.  Is there a straightforward way to do this? Would be grateful for a breakdown in how to complete this   Thanks in advance!
asked
2 answers
0

Hi Sophie Macleod,

 

It is not possible with default drop-down filters in the datagrid, but you achieve it by creating a data grid with custom filters.

 

You can follow this woderful post : https://medium.com/mendix/create-your-own-way-of-filter-by-npe-non-persistant-entity-and-microflow-4ffd11e52fb0

 

You can make use of the Selectable object in the Reference Selector, if you are using Mendix 10 you can make use of the Combo Box widget for more powerful filter features.

 

ATB!!

answered
0

This is one way that might work (note, this uses view entities which are beta in 10.19): 

 

This data grid has 3 cascading drop-downs - first you select country, then the cities in that country, then a relevant zip code:

The grid will show all customers that have a delivery address that matched (part of) the selection 

 

image.png

 

The filter section uses an NPE with your filter settings:

 

image.png

 

The cascading drop-down use a view entity to query the data for the dropdown:

 

image.png

 

Every dropdown is filtered by the previous dropdown selection:

image.png

 

The data grid filters by these NPE selections:

 

image.png

 

The grid itself has a view entity as datasource that joins customer with delivery address:

 

image.png

 

The approach will still enable you to add filters per grid, and sorting and pagination will also work out of the box without writing a single microflow for the data retrieval:

 

image.png

 

You can use the view entity to generate informative labels, e.g., include the number of items in the next dropdown, or the number of items in the resulting datagrid:

 

image.png

answered