Wildcard (*) syntax in conditional where()

Hi,

I am using on the frontend, serverconnect.data.query1.where (“Column Name”, Variable, “==”) as an expression for a repeat. Then, depending on user input, Variable will change between different options (Value 1, Value 2, etc). This part is working great.

Now, if I want to show all the collection, how can I set programmatically the Variable to Wildcard(*) to signify all possible values of “Column Name”? Setting the Variable to * which is equivalent to (“Column Name”, *, “==”) is not showing any entry

Thank you!

Hi. I think you need to use repeat condition for values which are not null. So try using null in value and != in operator.

2 Likes

Hi Elias,
I believe in your case you’d better use the Data View component to display the data on the page, then setup its filtering options to only filter data, when the variable has value, otherwise show all.

So the idea is - you create your server action, which gets the data from the database, then on the front end you add the data view component which loads the data once and you can sort or or filter it fully client side.
Then you just use your data view as a data source for the repeat regions on the page.

Thank you @sid and @Teodor
@Teodor,
Is the following scenario what you’re recommending?
For the DataView, under filter property: var_filter.value
On click for Button 1 (Scenario A): var_filter.setValue(“ColumnName == ‘A’”)
On click for Button 2 (Scenario B): var_filter.setValue(“ColumnName == ‘B’”)
On click for Button 3 (All Scenarios): var_filter.setValue()
for the row repeat, expression: DataView.data

On the other @sid’s proposition worked.
I implemented it as follow in case someone else needs the same and the data loads once from the DB as if a DataView was implemented.
On click for Button 1 (Scenario A): var_filter.setValue(“A”);var_filteroperator.setValue("==")
On click for Button 2 (Scenario B): var_filter.setValue(“B”);var_filteroperator.setValue("==")
On click for Button 3 (Show All Scenarios): var_filter.setValue(“”);var_filteroperator.setValue("!=")
for the row repeat, expression: ServerConnect.data.query1.where(“ColumnName”, var_filter.value, var_filteroperator.value).
Thank you both

2 Likes