Filter drop down by other drop down

0
is it possible to filter drop down by other drop down in Mendix 6 in search area (top of the data grid)?
asked
4 answers
3

Amer,

In the standard search options this is not possible. To do this you would need to create a construct that will filter a grid based on selections in a helper entity and perform the constraints and searches yourself. Edit: Create an entity with the search fields and associations needed. Make sure the new entity has an association to the data you want to search on. On a page create a dataview with the new entity and a grid with the entity you want to search on. Also add a button that will take the new entity as input and create the search function with a database retrieve action. The result of the db retrieve is linked to the new entity. So now you have an search entity object with the associated data that you wanted to search on. As last action of the microflow refresh the new entity and the results are shown in the grid. This will give you the option to constrain selections in the 'search' fields like on a normal form.

answered
1

Yes, you can constrain by associations. For instance, we have a form for selecting employees and in the drop down above, you choose the employee title, and the dropdown below is constrained to the title. You do have to be careful though because if you are going to use the same form for another purpose, the same association has to be set before you open the form.

answered
1

Amer, to set up Erwin's suggestion which should work for you, create a new entity in your domain model with associations to your two drop-down search entities, and another Reference Set association to the entity you wish to display in the table field. Create a data view form for this new entity with the two drop-down search fields at the top - set an x-path constraint or a constrained-by on the second drop-down so it's values are constrained by the first drop-down. Create on-change microflows on both drop-down fields to retrieve the matching datagrid objects, and set the result set to the reference set of your new entity and refresh. Below the search drop-downs, add a datagrid based on the Reference Set. You can also add other standard search fields in the search area for the datagrid. That's basically it.

Obviously, to use this you first have to create a record of the new entity to pass to the data view you open, so you need to set up a microflow on your menu to do this. You might add an association to the current user so you can re-use the helper entity rather than creating a new one each time.

answered
0

in order to implement a filtered drop dow list from another down down list, you must:

1) open the page where you want to do this

2) make sure you have the 1st drop down list before 2nd so that the user can select a value from the 1st

3) go to properties of the 2nd drop down list

4)  go to the selected objects tab

5) select source = xpath

6) un the constrained by area, cliick edit in order to select the 1st drop down list reference

7)  you can alos speciffy the order by by clicking the edut button if the "set order" option

8) Save all

9) compile and run

Note:  the domail model must have the appropriate references setup in advance

 

Let me know if you have futher questions.

 

Daniel

 

answered