List/Grid empty after going out and back in to the screen

I have a List/Grid in a screen that shows document from a collection without any filter or query at all. I have some picker to save certain values in a dataSlot and filter the list/grid based on that. The way I have it right now is with the script in the item values:

var selectedCategories = "";
selectedCategories = this.context.appActions.dataSlots["ds_LevelFilter"] + this.context.appActions.dataSlots["ds_sublevel"] + this.context.appActions.dataSlots["ds_musicStyle"];
if (selectedCategories != ""){
	items=this.context.appActions.getDataSheet("arreglosFiltered").items;
}
return items;

It works perfectly fine. But I wanted the app to remember the last filter applied, so the user doesn’t have to filter again when revisiting the page. In order to achieve that, I checked the “Persistence” in the dataSlot column, however it works fine during the session -if the user is using the app and goes to another screen and goes back where the list/grid is located-, but if the user goes to a different address or close the app, when the screen is revisited, the list is shown empty. It shows no documents at all.

In the console it looks fine, it says that it is doing the query according to the filter that was selected in the previous session, but it doesn’t show anything. However, if the filter is changed to another value and then back to original that was empty, documents are back.

I am guessing that it is because the app identify that the value in the dataSlot is different when it actually changes, but it doesn’t check it in the first place. I don’t know.

Let me know if you need more info or screenshots. Thanks.

I have found a solution to the issue. I created two states of the screen, one of them has the list without any filters and the other one is filtered. I have established the state of the screen based on the dataSlot containing the filters so now when the user clicks to go the screen, the app checks if that dataSlot is empty or has some value to show the list entirely or filtered.

It works like a charm. Thank you!

1 Like