Reputation: 783
I wanted to filter my store but it doesn't work:
me.store.filter([{
filterFn: function(storeItem) {
Ext.iterate(storeItem.data, function(item) {
if (item === me.mainMenuItem) {
if (typeof(storeItem.data[item]) === 'number') {
//console.log(storeItem); returns what I want
return storeItem;
}
}
});
}
}]);
When I use this filter my store is empty even if few elements fullfill my conditions. How can I make it work?
Upvotes: 0
Views: 463
Reputation: 30082
The filterFn
expects you to return a boolean value that indicates whether or not the value matches or not. Currently, you're not returning anything from the filterFn
, you're returning a value on the inner iteration function, which isn't really useful here.
You want to do something like this:
me.store.filter([{
filterFn: function(rec) {
var data = rec.data,
key;
for (key in data) {
if (key === me.mainMenuItem && typeof data[key] === 'number') {
return true;
}
}
return false;
}
}]);
Upvotes: 1