Repeater facet filter (multi-select)


#1

Continuing the discussion from Multi-column facet filters:

Hi @josephxbrick,

I really liked your post. I’m trying to do a similar facet filtering but I want to have the select (checkboxes) generated dynamically - by another repeater.

h70olh.axshare.com

I tried to put the filter initiation on the selectRepeater (onItemLoad) like this:
[[ (!statusSelect) || (statusSelect && TargetItem.status == ‘Item.selectTitle’) ]]
statusSelected = is selected of [Item.repeaterCheckbox]

However, I cannot get it working. Do you think something like this is possible?

Many thanks in advance
Karel

multiselect-filter_v2.rp (188.4 KB)


#2

Hi!

It’s possible to use a repeater to hold the checkboxes, but it’s not possible to dynamically add a category (during runtime), because the filter must be aware of every possible value. (If you look at the filter in the facets-filter example, you’ll see why.)

Also, since there is no way to query which checkboxes are checked in a repeater from a filter, you’ll need to take a different tact. Assuming it’s cool to not dynamically add categories, here’s how you can use the facet filters method when the checkboxes are in a repeater. (I updated your example.)

Here, I’m updating a text label with each selected item in the repeater, using the listener method, and then querying that value in the filter. Aside from that, everything is the same as in the facet filters post that you mentioned.

I’m not sure what you plan to do with the “All” checkbox; I’m just showing all rows if none of the checkboxes is checked and am ignoring “All” if it’s checked.

Note that the function value.indexOf(string) returns the starting location of string inside of the value, so ‘abcd’.indexOf(‘a’) is 0, ‘abcd’.indexOf(‘b’) is 1, and ‘abcd’.indexOf(‘z’) is -1 (meaning not found). So if indexOf(string) is 0 or greater, you know that value contains string.

Preview

File: multiselect-filter_v2.rp (193.9 KB)


#3

Hi again!

I was wrong! You CAN dynamically (during runtime) add categories to both the dropdown repeater and the main repeater, with a much simpler filter. Here is the whole filter:

[[lv_checkedVals == ''  ||  lv_checkedVals.indexOf('+' +  Item.status + '+') >= 0) ]]

This basically says, “Show a row if lv_checkdVals is blank OR if lv_checkVals contains the current row’s ‘status’ value (surrounded by plus signs).”

The plus signs are tacked on to avoid a situation where, say, you have filter values ‘Blue’ and ‘Sky Blue’. Without the plus signs, ‘Blue’ would return both colors.

This method could be applied even if checkboxes are used outside of a repeater. I’d update the original Facet Filters post I made, but it’s locked for updates.

Updated file: multiselect-filter_v3.rp (193.8 KB)


#4

Hi again!

I updated my original facet-filters example (using checkboxes outside of a repeater) to use this method. I can’t update the original post, so I’ll put it here.

Note that there are two pages in this example, each showing a different number of filters. The explanations are in the file.

Preview

File: lastest_facet_filters.rp (133.4 KB)


#5

Awesome!!! This is great!!! Many thanks for your help. :grinning:

Just to clarify, the “All” checkbox should basically clear all filters and ideally also uncheck all checkboxes that are checked (…now I’m not sure if it is possible to dynamically influence other items in the same repeater…)

I will try to use your example and combine multiple filters and come back with the result.

Thanks again.


closed #6

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.