I have a simple dom repeat like this:
<template is="dom-repeat" items="{{projects}}" as="project" filter="{{computeFilter(searchString)}}">
[[project.name]] - [[project.number]]
</template>
<paper-input name="filter-name" label="Filter by project name" value="{{searchString}}"></paper-input>
And there is a function that filters the projects by name:
computeFilter: function(keyword) {
if (!keyword) {
return null;
} else {
keyword = keyword.toLowerCase();
return function(project) {
var name = project.name.toLowerCase();
return (name.indexOf(keyword) != -1);
};
}
}
All good. Now, how would I go about adding another filter, if for example I'd also like ot filter by project number?
I would have another paper button binding to {{searchString2}}, but then how would I link this to a filter - in other words, how can I set up multiple filters on a dom-repeat?
There's a way to filter a
dom-repeat
using multiple filters.First, here's the template:
You must define for each filter an observer to refresh the filter:
Then, you must use a filter function with your filters:
Here you can see an example of this method.