Losing the selection in the template grid after refreshing

Hey guys, I just started using mendix Studio Pro and until this moment it went quite well. But now I have a problem that I can’t seem to solve and I thought maybe someone of you has a good idea on how I can fix it. My situation: I’ve implemented a template grid and used a microflow with a GET-Call to fill it with my data. My requirements: I have to constantly update the data in the template grid because there is an external counter that should be shown with “live” data. I’ve used the refresh time functionality in the general tab of the “Edit Template Grid” -options which actually works fine. The user can select a single item of the template grid and delete them or change the status to “reported”. Here I use “Single selection and maintain” for the Selection mode in the Template Grid Settings. I also implemented “Delete” and “Report” buttons which all works fine. My Problem: Let’s say I use a refresh time of 5 seconds. The user selects an item of the template grid and when the system refreshes the grid the selection is gone. That is unacceptable for what I try to build. If a user wants to select an item and report it, but in the moment where he presses the “Report” Button the selection is lost he will get an error message which is very bad UX, because it’s not even his fault.  My thoughts on fixing it: I need a solid solution for my problem because this template grid is the centerpiece of my app. Simply increasing the refresh time and hoping the user won’t press a button in the wrong moment is not what I try to achieve. So I thought about some ways to fix this. One Idea is to instantly save the selection and add it after the refresh via custom code (if that’s somehow possible). The other idea is to change the functionality for the update of the external counter by not using the Refresh time option (if there is a way).   If anyone has an idea how I could fix my problem I would be very thankful. I’m also open to use another Data container like the data grid or the data grid 2, but there seem to be similar problems. Thanks for advance for any helpful comments :) ​​​​​​​
1 answers

Use a helper object and make two lists. One showing the live data which is constantly refreshing and the other one the helper object. Now when you select an object from the live data create a reference to the helper object. This way you can update the live data and still keep the selections by retrieving those from the helper object. And do make sure that the live list is the live list minus the already selected objects in the helper list.