Dynamically Filtering a Repeater
ATTENTION: THIS IS OUR OLD SITE. TO SEE OUR NEW WEBSITE, CLICK HERE.
The following code shows you how to implement a wildcard search and dropdown filter to a repeater, either separately or used in conjunction with each other. It shows you how to apply a wildcard search to more than one field in your collection at the same time e.g. search both text title and text body.
This example assumes you already know how to create a repeater and connect it to your dataset. The next step is to add a text input field for keyword searches and a dropbox for predefined option searches. This example will show you how to create the same functionality used on WixCodeBank to search for code by keyword or cost. Consequently, the inputs are given the aliases #iptSearch and #iptCost for this example. Add an onKeyPress event listener to the search box and an onChange event listener to the dropdown box.
Add the code which follows to the top of your page code. The global variables declared will store the search criteria used in order to check if a new search is warranted on a particular selection.
Please login or sign-up (it's free!) to view our code. Refresh the page if already logged in.
Disclaimer: To the best of our knowledge, this code works for its stipulated purpose. If you find an error in our code, or know of a better way to achieve the same result - please contact us! We will help where we can, however please be aware that the code is provided 'as is' and without a promise of support in using or implementing it.