Server side filtering

So I have a table which is filled by a PostgreSQL query.

Suppose I add a selection with which I want to optionally filter the table server side.

I can’t use a different query by just appending an " and field = ‘{{ mySelection }}’") because the table is tied to the original query and the additional constraint should only apply if something in the selection is actually selected.

Next I thought about doing something like

storeValue("filter", " and field = '{{ mySelection }}')

in the selection’s onChange and putting {{appsmith.store.filter}} into the original query, doesn’t work either, because on load, {{appsmith.store.filter}} is null. Is there an onLoad event I could hook into to set appsmith.store.filter to “” ?

Any other alternatives?

Ok, found the solution here:

Define the myQuery like this

SELECT * FROM orders where {{this?.params?.condition || "1=1"}}

and call it like this

myQuery.run(() => {},() => {},{"condition": "status = '"+selFilterStatus.selectedOptionValue+"'"})

(selFilterStatus is the selection with possible status filter strings in my case)

@arminus Glad you found the workaround. We will also be working a feature to add load events for widgets which you can track here - [Feature]: Add load event for widgets · Issue #10528 · appsmithorg/appsmith · GitHub