0
votes

Does anyone know if there is a wildcard character in AppMaker that can be used for all possible values for a field in a query?

I currently have a datasource that is being filtered based on the status using a multi-select widget. What I would like to accomplish is when all values have been de-selected I want to load all the records of that datasource without clearing the entire query in case other filters have been applied. I have it working in-a-sense that I have to explicitly construct my query as such:

widget.datasource.query.filters.Status._in = ['Status Value 1','Status Value 2','Status Value 3']

My current solution is loading the correct data when a value is selected and it correctly shows the union of the query as the values are modified. However, it selects all of the values in my multi-select; which I know is how it is supposed to work.

I tried using widget.datasource.query.filters.Status._contains = ''; and changing the assignment value to no avail. I even tried the opposite approach using _notContains

The intended outcome is to have a filtering dashboard appear much like any website where when no filtering is selected all records are displayed. I was hoping to find a wildcard character that would load all of the records. Just trying to find a way to mimic other website filters with all records when none are selected.

Thanks for the time!

1
A values binding on the multiselect of @datasource.query.filters.Status._in doesn't work for you? Why are you intermixing contains with in when you are trying to clear the filter? - Markus Malessa
It does in fact work; however, trying to clear filter for just that field without using the `._in' is not an option apparently. Just trying to clear that field filter specifically. - Daniel Wampler
Unfortunately App Maker was not built with the functionality to only clear filters on specific fields. The only way to get that accomplished is to set the input value(s) to null, in which case if you reload the datasource any previous filter will be reset to no value for that filter which is the same as ignoring that filter. So you would either need to manually deselect all options, or maybe introduce a button next to the specific widget that would do widget.value = null or widget.values = [] and then still reload the datasource. - Markus Malessa
I attempted that solution as well and since there were no values in the values array, it loaded no data since there were no records with a status value of null. I realize this is trying to break the already thought-of querying functionality but was hoping maybe there could have been a wildcard ability. Thanks for the advice and letting me know I already had a working solution that aligns with your suggestion. - Daniel Wampler

1 Answers

0
votes

So the easiest solution here is to set up your Multiselect as follows:

Options binding:

@models.YourModel.fields.Status.possibleValues

or if you don't have the possible Status values in your model then set your options binding to:

['Status Value 1','Status Value 2','Status Value 3']

Values binding:

@datasource.query.filters.Status._in

Now anytime you select any choices in the multiselect, the query will only include records that include the selected choices. And if you deselect all choices the query will ignore that filter or treat it as an empty array of values, therefore returning all records unless you applied other filters.