Iam trying to apply several filter which I get from a localStorage store.
I load the store and can apply some filters:
var newsStore = Ext.getStore("cityStore");
newsStore.filter(Ext.create('Ext.util.Filter', {
filterFn: function(item) {
return item.get('name') == 'city1' || item.get('name') == 'city2';
}
}));
But now I have a list of items and would like to iterate through all items in the list and apply them to the store filter.
The problem is imho that I cannot iterate though a loop and do return item.get(‘name’) == ‘variable’ again and again because this would only filter for the last return but I would like to apply every item in the list as the filter seen above.
Hope I can find some help here…
Thanks!
Imaging you have an array containing the names you have to use for filtering the store, we will call this array ‘names’:
What you have to do in your filterFn is return true if the record contains some of the values listed in your names array. The magic is in the some function.
For example, the following store will only contain 2 rows (after apply the filter): Lucas and Pablo:
You also can do it working here: http://jsfiddle.net/lontivero/5TWq9/3/
I hope this is useful.
Good luck!