Hi Joe,
You can use a small trick to achieve this with a Database as Grid2 source. The idea is to prevent the grid from retrieving data until the user has entered some search/filter criteria.
Here’s how you can do it:
Create a helper non-persistable entity (don't worry this is not for custom search or external filters)
Add a Boolean attribute called IsSearch and set its default value to false.
Add additional attributes corresponding to each of the search/filter columns in your Grid2.
Place the Grid2 inside a Data View
Use the helper non-persistable entity as the Data View’s context.
Add an XPath constraint to the Grid2
[$Helper/IsSearch]
When IsSearch is false, the Grid2 will return an empty list, preventing unnecessary data retrieval.
Handle filter changes
On each search/filter input, save the value to the corresponding attribute in the helper entity.
Add a microflow on change for each filter that:
Checks if any filter values are filled
If any value is filled, set IsSearch = true → Grid2 will retrieve matching data
If all filters are empty, set IsSearch = false → Grid2 remains empty
Result:
The grid only retrieves data when the user actually uses the search/filter inputs.
This improves performance and avoids loading unnecessary data.
I hope this works for you, and let me know if you have any questions.
Hi Joe,
If I understood correctly, you want a grid/list to not show any data on initial page load, even though the Data source = Database, and only load data after the user applies a filter.
Short answer: With Data source = Database, there’s no single “checkbox” to prevent the initial retrieve as soon as the widget renders.
Workarounds:
Option 1: NP Search Context + Conditional Visibility:
Store your filters in a Non-Persistent Entity (NPE) and place the filter inputs outside the list/grid. Add a Search button and use it to toggle the list’s Conditional visibility (e.g., HasSearched = true). As long as the list is hidden, its objects are not fetched. This requires extra effort and increases the number of clicks for the user because they need to click the Search button.
Option 2: “Impossible” XPath constraint:
Configure the DB XPath constraint so that it returns no results until a filter is filled
e.g. require CustomerNumber: [CustomerNumber = $SearchContext/CustomerNumber]
Or use an initial value you’re 100% sure doesn’t exist in the DB to force an empty result set.
However, although it looks like it works in theory, it’s not easy to explain what kinds of problems this can bring in real-life scenarios.
Hope these help!
hello Joe,
What do you exactly want?
Joe,
Do you mean the behavior of Filer(s)?
The Mendix documentation reads: To have better control of when the filter will be applied, we offer a Apply after (ms) option under the On change behavior group. This option will only trigger the filter after a predefined period of time while typing. By default, Mendix suggests 500ms.
Setting it to a larger value prefends action after typing one character, but unfortunally it waits full period after an enter key or after leaving the inputfield.
OK thanks. Is there a reason for dropping this function as it is very useful to us, especially when the user is using the grid to search for items, it isn't great to first show them data that is not applicable to them? Will it be added at some point?
thanks
Hi Mohammad
I have set it up. But, the on change MF does not fire at all. Is there an issue with this for custom filters? thanks
Hi Mohammad
these are the MF settings
here is the MF
But its just not firing when I add text into the filter