Table filter stack not being cleared

Hi,

Started using the new table with filters recently and think there may be an issue with how the filters are working.

Attached run through of the issue I'm seeing but basically the filters dont appear to be cleared correctly when using either the "Clear Filters" button or via code.

In the example I have an event handler on close of the modal set to clear the filter stack but you can see that despite the filterStack showing as "undefined" in the state window, whenever I reopen the filter window after a window close, the filter has turned up again.

I dont have any default filters set in the component or in code.

Apart from this appearing to be a bug, its also causing needless query runs when opening the filter window.

Cheers

Rob
Retool-Table Filters

Hey Rob,

It should expected that when you click on the filters there is a placeholder empty value there by design. However, this should not actually be altering what you see in the table and is just there to illustrate where to enter in your filters - are you seeing that the results are different when that empty placeholder is there vs. when the filters are cleared specifically cleared?

That said, the part that I'm not able to reproduce is the repeated triggering of the query that feeds into the table. Can I ask how you have this query set up, is that being run based on input changes and if so, what inputs are being used? Or is this being run from a manual trigger instead?

Any more detail you can provide here would be helpful, thanks!

HI @LaurenM , thanks for taking a look.

The table / query are behaving strangely in general.

For example, see the screen shot below. You can see I have opened the modal containing the table and the queries have ran twice. At this point I have not set a filter etc. The query "sql_get_all_assets" is set to only run when manually triggered. In the Open event for the modal I trigger "Clear filter stack" to clear filters and rerun the query. For some reason it runs twice. The query is then triggered by either the "Change Filter" or "Change Page" event in the table. event handlers.

In the next screen grab below I have simply clicked the "Filters" button in the table. You're quite right, it does display an empty placeholder, but, as you can see it then runs the queries a further 3 times and at this point I havent actually added search criteria (NB the asset count query is triggered on Success of the get all assets query).

You can see its definitely rerunning the query based on the empty placeholder (i.e. empty value and therefore no results returned). Whats more strange is the fact its running it three times?

With regards the default filter / placeholder. I actually have the "Default Filter" for the table set as No filters, yet it seems to be ignored and defaults to "Asset ID"? If I actually set a default filter, then when I click the filters button it ignores the field I have set as default and reverts to "Asset ID" anyway. I have actually put in a feature request to have an "Apply Filter" button here Feature Request.

I've attached an export of my app if that helps track down either what I'm doing incorrectly of the bug.

Cheers,

Rob
Routing Tasks.json (2 Bytes)

Hi @LaurenM ,

I've been taking a further look into this and I think its because both the "Change Filter" & "Change Page" events are set to rerun the query. By changing the filter the page will also then be changing I assume which is triggering the query a second / third time.

I removed the Change Page trigger and then it works as expected whereby opening the table only runs the query once. However the problem is then that changing page has no effect and only the first page of results can be displayed.

Still have the same issue with the query running multiple times when clicking "Filters" even without adding filter criteria. Overall it seems to be fairly inconsistent in its behaviour. With the page change event handler in place sometimes it will run the query once, occasionally three or even four times. Ive managed to mitigate it slightly by adding a throttle of 2 secs to those triggers ... all just seems a little "messy" though.

Cheers,

Rob

Hey Rob,

I agree, it sounds like you have a few too many event handlers in place that trigger that same query. With the new table, pagination and filtering are built-in to the table options. This means you don't need event handlers to move to the next page or when adding filters as Retool will handle this directly.

Let me know if you're still seeing these same issues after having removed those additional event handlers.

Thanks @LaurenM , Ive removed all event handlers and changed the query to run automatically.

This has solved the issue with it running multiple times on load.

However, it now retains any filters set and the page/offset it was on before the modal is closed (i.e. every time I open the modal it has the previous filter / page set).

The only way I can clear these is either an on close / open event and clear the filter stack ... but then it runs all the queries two or three times again when the stack is reset.

Also now, when I attempt to filter its running the queries six times to apply the filter? (see screen shot).

@LaurenM ... sooo .. I think I've been overthinking this! :man_facepalming:t3:

Set the query to only run on manual ... then (of course) .. set the filters and hit refresh ... which was the key bit I was missing. For some reason I had refresh stuck in my head as "reset" ...

Apologies for wasting your time, just off to bang my head against a wall ...

Cheers,

Rob

Hey @Rob_Faulkner - no time wasted at all! I'm glad you were able to figure this out!