DataGrid 2 not updating when using non-persistent filter from Nanoflow DataView

0
Hi everyone, I’m running into a confusing behavior with DataGrid 2 and a non-persistent filter entity, and I’d like to check if this is expected or if I’m missing something obvious. I have a main module with a Vehicle entity, which has a 1-* association with ServiceOrder from another module. ServiceOrder has a Status ENUM (InProgress, Waiting, Completed). On my Home page, I’m using a DataView with a Nanoflow data source that simply creates and returns a non-persistent filter object (FilterVehicle). This filter object only contains one attribute, SelectedStatus, using the same ENUM as ServiceOrder. Inside this same DataView, I have three cards that act as filter buttons (one per status). When a user clicks a card, a Nanoflow runs and updates SelectedStatus. Below the cards, still inside the same DataView, there is a DataGrid 2whose data source is a Microflow. This microflow receives the filter object as a parameter and returns a list of vehicles filtered by the status of their related service orders. The idea is simple: clicking a card should refresh the grid, and clicking it again should clear the filter and show all vehicles. The issue is that when I only use Change Object with “Refresh in client = Yes” in the filter Nanoflow, the DataGrid 2 does not re-execute its data source microflow. The filter attribute does change correctly, but the grid does not refresh. However, if I use Refresh object / Refresh entity in the Nanoflow, the DataGrid 2 data source does execute as expected. The problem is that this also causes the Nanoflow data source of the DataView to be re-triggered. In the debugger, it looks like the DataView DS gets stuck or paused at the End Event, as if the object is being recreated and the UI enters a reactive loop. Everything is inside the same DataView, nothing is being committed, and the DataGrid 2 does receive the filter object as a parameter, which is also used inside the microflow. From what I can tell, it seems that DataGrid 2 only refreshes when it detects a “real” dependency, and simply changing a non-persistent object inside a DataView is not always enough. Using Refresh object forces the refresh, but at the cost of re-executing the DataView data source, which leads to confusing behavior in the debugger.  
asked
1 answers
1

This issue is caused by using a non-persistent filter object as both the context of a DataView and a client-side state that is modified by a nanoflow. In this setup, Mendix does not always interpret a client-side change as a strong enough trigger to re-execute the Data Grid 2 microflow data source, while stronger refresh actions also re-trigger the DataView data source and lead to confusing behavior.

 

The most reliable solution is to separate the lifecycle of the filter object from the DataView. Instead of creating the filter object in the DataView’s nanoflow data source, create it once before opening the page and pass it as the page context. Then, use a microflow (instead of a nanoflow) on the filter cards to update the SelectedStatus attribute and refresh the object in the client. This keeps the page context stable, prevents the DataView from being re-executed, and ensures the Data Grid 2 reliably refreshes its data whenever the filter changes.

answered