EloquentStudio / filter.js

Complete solution for client side filtering and rendering using JSON data
http://eloquentstudio.github.io/filter.js
MIT License
664 stars 183 forks source link

Question about filtering #159

Open delco821 opened 6 years ago

delco821 commented 6 years ago

First of all thank you for this great example of client side filtering. There are so many useful ways to use this concept. In one of the examples (bytepartners), i saw a different use of adding filters. Instead of .Addcriteria, i see .addFilter, and it seems to be behaving different. Within the same filtering group, the filter elements are considered as they have AND between them, instead of OR. In other words, the checkboxes are behaving like radio buttons. I am wondering if it's this section where I need to make modifications to correct the issue: var include = true; while (f-- && include) { var filter = filters[f]; if (typeof urlFilters[filter.key] == 'undefined') { urlFilters[filter.key] = filter.value; } else if (urlFilters[filter.key].indexOf(filter.value) === -1) { urlFilters[filter.key] += ',' + filter.value; }

            if(item[filter.key].constructor === Array) {
                if (item[filter.key].includes(filter.value)) {
                    continue; 
                } else {
                    include = false; 
                }
            }

Any assistance is much appreciated.