Refreshing data in a DataGrid2 widget from microflow

0
Either I am being silly and missing something extremely basic, or Mendix as a platform is being silly and failed to implement something extremely basic. I have a datagrid2 widget that fetches a list of records from an entity <CityRide>. The screen with this datagrid2 contains a dataview, which contains the datagrid. My bottom line issue is this: I do not know how to call a microflow, then have a datagrid that uses that microflow as its source refresh its results to the returned results of the microflow when I call it.   This screen uses a multi grid filter with a text filter, and that works great. The issue lies in the fact that the multi grid filtering is an abstracted, platform function that I have no control over. This means that when I try to add in a switch toggle to display only active records, or all records I seem to be unable to get that fetched data to refresh in the datagrid. Before I switched over to using the datagrid native filtering widget, I had the same issue with the text filters. The microflow would correctly filter and return different results, yet the data grid would never refresh itself. I am Committing the list and calling Synchronize (as some other forum post mentioned doing). For my test, I am just creating an empty list and returning it if the switch toggle is false so I can clearly see it working, and its not.   Here is my microflow which is set as the datagrid2 data source. If the passes in value from the SearchFilters/OnlyShowIsActive is false, then return an empty list and refresh the data grid 2.   The page has a parameter "TempSearchFilters" of type <CityRideSearch>:   This uses a non-persistable entity called "CityRideSearch":   This is the data view which holds the data grid 2 which uses the page parameter "TempSearchFilters":   This is the data grid 2:   The switch calls the "FetchCityRideRecordsWithSearchFilter" microflow, which is supposed to filter the results and refresh the data grid 2:     Why is the data grid 2 not refreshing its data to show no results? How can I update the results of a datagrid via a microflow? This example is very basic, but I know for a fact in the future I will have more complex situations that require the same basic use case: refresh a datagrid with the results from a microflow. Since Mendix loves to abstract away functionality, I would have assumed that it could automatically pickup the fact that same microflow was called and to refresh any widgets that use that microflow as a data source. (I am also on Mendix 10.14.0 which isn't even an option below)
asked
3 answers
0

Hi Alex,

 

The way that I typically accomplish this is to have an association on the search NPE to the CityRide entity. When the search is executed, you can clear and re-populate this association with the search results, as long as you have the refresh client box checked the data grid will update.

 

For this to work you will need to have the data grid populated over the association to the search NPE.  You can have the microflow that is the data source to your data view load an unfiltered list of CityRide.

answered
0

I attempted to implement this by creating a new app and followed all of the steps outlined below:

Create a new entity in to domain model:

image.png

 

Create a NPE and create an association to the entity created prior:

image.png

 

Generate overview pages for the entity using the built in entity actions:

image.png

 

Create a data view and place the data grid inside the data view. This is required because otherwise I cannot assign a value to the switch widget:

image.png

 

Assign the data view to a microflow which returns a new "TestSearch" object:

image.png

image.png

 

Create a multi grid filter over the text attribute with a text filter widget (and some cleanup and adjustments to the table):

image.png

 

Go to change the switch On Change event to a microflow...

image.png

 

What exactly am I doing here in this microflow? You mention clearing and re-populating the association with the search results, how do I do that? I also can't set the data grid to an association because it won't let me. If I select the data source to be an association, it doesn't let me select one:

image.png

 

If I select database as the source, then it will show the associations as an option:

image.png

 

But it will give me an error if I try to select it...

image.png

 

What on earth do I need to do to achieve this extremely basic test exercise?

answered
0

I was able to get this working via the NPE association, I will document the complete steps from start to finish for future reference once i have the time.

answered