Hi!
What you are trying to do is an example of facet filters. There’s a useful post on it here. I’d also acquaint yourself with local variables, as they are much handier than global ones in this situation. Read this post.
You’ll want one filter per “facet.” One of your facets is vehicle type, and the other facet is color type. Note: since you are defining more than one filter, be sure to uncheck the “delete other filters” checkbox when defining the second one.
The first one is easy. This assumes that LVAR_vehicle is a local variable referring to the selected option of the vehicle dropdown:
[[ Item.vehicle == LVAR_vehicle ]]
The second one is more complicated. You want all rows for the given vehicle to show when no color checkboxes are checked, red rows to show when the red checkbox is checked, and the same with blue and silver.
The important thing to know about filters is that they must always return TRUE or FALSE for a given row. If they evaluate to TRUE, the row shows up.
Your second filter looks like this, again using local variables for the selected values of the checkboxes. For example, LVAR_blue will be TRUE when the blue checkbox is checked.
[[ ( !LVAR_red && !LVAR_blue && !LVAR_silver ) || (LVAR_blue && Item.color == ‘blue’) || (LVAR_red && Item.color == ‘red’) || (LVAR_silver && Item.color == ‘silver’) ]]
Note that the whole filter could be rewritten like this, which may be easier to understand, but is quite a bit longer:
[[ ( LVAR_red != true && LVAR_blue != true && LVAR_silver != true ) || (LVAR_blue == true && Item.color == ‘blue’) || (LVAR_red == true && Item.color == ‘red’) || (LVAR_silver == true && Item.color == ‘silver’) ]]
(The != means ‘not equal,’ && means AND, and || means OR. Note that ‘true’ must be lower case, for whatever reason.)
So the first expression in parentheses says “Red is not checked and blue is not checked and silver is not checked.” The expression evaluates to TRUE when everything is unchecked, so the filter will be true for every row since it doesn’t depend on a row value.
(Since these expressions are OR’ed together, if any of them is true for a given row, then the whole filter is true for the given row.)
The other three expressions evaluate to true when the row has the color of the corresponding selected checkbox. The values in the expressions are case sensitive, so be sure to capitalize the color names (in quotes) if they are capitalized in your repeater.
Note that filters stay around once defined, so you can define these filters just once, e.g., in OnLoad (not OnItemLoad) of the repeater, or in OnPageLoad. (In the example they are defined in OnLoad of the repeater.)
You then just have to force them to re-evaluate when something changes. To do that you put a command in OnSelectChange of the dropdown and each checkbox. (You can set the repeater’s items per page unlimited, which will force the filters to rerun.)
Here is a sample file. Again, I’d encourage you to go through the facet filter file above.
File: vehicle-facet-filters.rp (62.9 KB)