How to filter mobile collection view using text input?

I'd like to make a filter on a collectionView using a text box on the mobile app. The goal would be a simple filter on the name column on the results of the query that populates the collectionView vs. rerunning the query with where conditions with each change of the text box content. This functionality is much easier to implement in the web version of retool. Any help on where and how to build the filter (transform within the query, filter applied to the collectionView, stand alone JS service, other approaches) would be much appreciated.

Hey @geoffsharris!

I think how to best filter often depends on how much data you have and whether you're more comfortable using JavaScript or SQL.

If you're more comfortable with SQL you'd either want to build the filters into your SQL query or use a Query JSON with SQL query. The former is good for larger SQL datasets and the latter is good if you're using another type of resource like a REST API, or if your dataset is relatively small and you're comfortable doing all of the filtering on the frontend.

You can set the Query JSON with SQL query to run automatically when inputs change but it can be helpful for the performance of your app to set it to run only when manually triggered and manage when it runs using various event handlers on your queries and components. Either way, you'd be passing {{ }} to your collection view.

If you rather go the JavaScript route then JavaScript queries offer a similar amount of control to manually run Query JSON with SQL queries. You can use event handlers to run your filter script when you want and then pass {{ }} to the collection. Alternatively, standalone transfomers will do a lot of what an automatically run JavaScript query would do, so if you don't want to configure event handlers that's an option to consider.

Query transformers aren't particularly ideal in this case since they will only run when your query runs but still modify the data after it has been returned. They're useful for formatting query data but if you're looking to do filtering you're likely better of with one of the other options mentioned above.

Let me know if that's a helpful start and if it raises any additional questions!