The term for multiple filters winnowing down a list is “facet filters.” The first facet is the search text, and the second is the value of the dropdown.
We’ll use technique for solving this problem here. NOTE! Please go through this sample before reading the rest of the explanation, because otherwise it won’t make sense.
Note that in my modification of your file, I am setting Items Per Page of the repeater to Unlimited to force re-evaluation of the filters defined in onPageLoad, rather than a do-nothing filter. (It might be my imagination, but seems like it performs better.) Also, note that we never need to hide or show the repeater itself, as the filter automatically returns no rows when none of the rules apply.
Let’s look at the two facet filters defined in OnPageLoad one by one, because your situation is obviously different than the one set up in the facet filters post:
[[ ( sVal != "" && Item.Col1.toLowerCase().indexOf(sVal.toLowerCase() ) >= 0) || ( sVal != "" && Item.Col2.toLowerCase().indexOf(sVal.toLowerCase() ) >= 0) || ( sVal != "" && Item.Col3.toLowerCase().indexOf(sVal.toLowerCase() ) >= 0)]]
That’s a long expression, but we really only need to discuss the first third. But first I’ll point out that && is a logical AND, || is a logical OR, != means not equals, and == means equals.
( sVal != "" && Item.Col1.toLowerCase().indexOf(sVal.toLowerCase() ) >= 0)
You are familiar with the part of the expression after the AND. Unfortunately, if the first parameter of .indexOf( ) is an empty string – e.g., if the search field is empty – the function always returns TRUE. So we have to AND that expression with a second expression, sVal != “”, to rule that out.
In English, the expression above says, "If the search text is not an empty string and Col1 contains the search text for a given row, return TRUE.
The next two expressions in the long expression are just like this one except targeting a different column, and the thee are OR-ed together, so that if any one of these things is TRUE for a given row, the whole expression will evaluate to TRUE.
The second facet filter further reduces the results of the first:
[[ sfVal == "All Records" || sfVal == Item.Col3 ]]
There are two conditions here OR-ed together:
sfVal == "All Records"
This basically returns all of the resultant rows of the first filter if the value of the result filter is All Records. Remember from the facet filters post, a filter doesn’t need to reference a column value at all; it merely needs to return TRUE or FALSE. This expression snippet will return true (thus the entire expression will return true) if the filter value is All Records.
The other possibility that we want to cover is if the filter value matches Col3 for the given row. (Note that I made the values in the filter dropdown exactly match the values in Col3. If you don’t want that to be the case, let me know and I can help you work around it.)
sfVal == Item.Col3
This returns true if the value in Col3 matches the filter.
So in English, the whole second filter means, "If the search filter is “All Records” or the search filter matches the value for Col3 for a given row, return TRUE.
I updated your file.
file: Search Filter.rp (92.1 KB)
[Edit] I made the assumption that if the user selects a filter aside from All Records WITHOUT entering any text in the search field, no rows will be returned. Which makes sense logically, since when the filter says All Records, no rows are returned. But the user may be confused if, say, they don’t enter any search criterion and choose Employee from the filter, and nothing happens.
Would you want to show all employee rows in this scenario? If so, let me know. I’m sure we can adjust the filters to accommodate this scenario, but it would be a bit more complex. However, since this state is ambiguous, expectations could go either way. it might be best to disable the filter if no text is in the search field.