Set datasource based on radiobutton checked

1
On a page I have a list view and a dataview. - The dataview contains filters (e.g. ‘Bike’, ‘Helmet’, ‘Gloves’, etc.) - The listview has to contain the attributes of a specific entity based on the filter checked in the dataview. Example: As a user, I click on Bike (RadioButton), next the list view will load all attributes of entity ‘Bike’. If I then click on Helmet (RadioButton), the listview should load al attributes of entity ‘Helmet’. Is this possible?
asked
7 answers
1

- I created a new Entity "all_Products" → contains all types of products. = Good
- I created a page containing a listview nested in a dataview - The dataview’s datasource is the entity “All_Products” = Good
- The listview’s datasource is a microflow. = Good

- The microflow get’s triggered by the OnChange event of the radiobuttons. = this is wrong. 
The onchange event should only perform a refresh (Onchange, w/o change members and just a refresh)

See this microflow: https://modelshare.mendix.com/models/8c335fd2-be33-4fdd-a0a0-67df21ef750b/och-refresh-search

the datasource mf of the listview will then be triggered and return the list to the listview



 

answered
3

Hi Jannes,

In addition to the answers of Andreas;

An option would be to have a non persistable entity to capture your search/filter value:

Create the page like this; an dataview containing the NP search object and a nested list;

Refresh the ProductSearch object onchange → this will trigger the Datasource of your nested list to retrieve the correct list.

 

On another note:

  1. Why using specializations?
  2. Adding the product type in you Product entity will allow you to constrain it using XPath: //Product[ProductType = ProductSearch/ProductType]
  3. ListView control widgets might give a better experience: https://appstore.home.mendix.com/link/app/105694/

 

good luck ;-)

 

answered
2

You could add a helper entity and place it around your dataview. Place your selections in your helper entity and trigger a refresh on change. This will also refresh the nested listview.

Use a datasource microflow for your listview that returns the objects based on the selection in your helper. The helper is available as parameter in your datasource microflow.

answered
1

Sorry, I thought I understood it but apparently not. 
See following microflow. Basically i check which radiobutton is checked and then I retrieve a list based on the outcome of the decision. Finaly, I create an end-event for each outcome and return the representative list.

 

answered
1

Maybe I haven’t explained everything completely.
At this point I have 9 entities.

  1. One is the entity “Product” → which contains all the basic data that all other entities can use.
  2. The rest are entities like “Helmet”, “Pants”, “Shirt”,… which inherent the attributes from entity Product.

 

The entity “Product” contains a attribute product_type (enumeration) which I want to use as a filter to set the datasource of the listview.

At this point i created the following: 
A page containing a dataview (source = “product”) containing radiobuttons for filters. In the dataview I also have a listview with datasource set to “microflow”. The microflow contains a decision that checks which radiobutton is selected, then retrieves a list of objects associated with that decision, then I use a “change object”-activity to refresh the page and set the end event return type to list (list type depends on the outcome of the decision).

Is this possible? Because as far as I know the nested listview doesn’t know which end-event to pick in the microflow so he just picks the one where the decision outcome is set to “empty”
 

answered
1

The listview does not decide which endpoint is used, the microflow does that. Whatever the microflow returns (It does not matter which endpoint) will be used by the ListView.

I still think the problem is your refresh. You are doing the refresh in your datasource microflow but once this refresh is done, it does not refresh if you change the selection on your enum (In your dataview). This selection needs to have an onChange microflow that refreshes your Product object. This should cause the datasource microflow to run again and return the updated list.

answered
0

@rené van Hofwegen
- I created a new Entity "all_Products" → contains all types of products.
- I created a page containing a listview nested in a dataview 
- The dataview’s datasource is the entity “All_Products”
- The listview’s datasource is a microflow.

- The microflow get’s triggered by the OnChange event of the radiobuttons.

Am I still doing something wrong in this case?
 

answered