Filtering table with search term passed via urlparams not working

Hi all :wave:

As the title suggests, I'm having troubles getting table-filtering based on urlparams to work.

Here's what I have so far:

  • I have a text-input tableSearchInput, that's configured to keep in sync with urlparams.hash.searchTerm. This works :white_check_mark:
  • I have a table, that has the search term set to {{tableSearchInput.value}}. This filters the table if I directly change the value of tableSearchInput :white_check_mark:

Now here's the issue:

If I navigate to the app with a #searchTerm=something, I can see that tableSearchInput has the correct value, but the table isn't filtered. Only if I trigger a change event on the tableSearchInput (e.g. press and delete space), does the filtering actually take place.

The data for the table is obtained via an async API call, so maybe that's the issue? Then again, it seems like this is one of the most basic things you'd want to implement with retool, so I'm kinda stumped this doesn't work out of the box.

Thus my question:

Is this the expected behaviour, or is this a bug, or am I doing something wrong here?

Or how would I achieve filtering a table with a fuzzy search term passed via urlparams?

(PS: If the table has demo data, it works btw. So maybe this really is a race condition with async API calls?)

Looking forward to your reply!

(PS: If the table has demo data, it works btw. So maybe this really is a race condition with async API calls?)

This...

Perhaps try delaying the urlparams being populated into the search and do it after the API completes as a Success event handler Run script, or something else?

1 Like

Thanks for the tip, ScottR! It's working now, albeit with some caveats :slight_smile:

  • I've configured a success handler on the query with tableSearchInput.setValue(urlparams.hash.searchTerm);, and a debounce rate of 500
  • I've removed the entire url parameters setup for searchTerm

So while the url param isn't kept in sync now anymore, at least the pre-applied filter works when navigating to the app.

1 Like