I have a "dstore/Memory" object declared like so:
this.flightStore = new Memory({
data: flights,
idProperty: 'myId'
});
I want to get back a filtered collection to display. So I write this:
var test = this.flightStore.filter({matchType:view});
That returns a 'test' object but the 'data' field is null. Yet when I write identical code but add on a forEach function:
this.flightStore.filter({matchType:view}).forEach(function(flight) { ... }
This works perfectly and I get back my filtered results one-by-one. From there I can build an array for my filtered collection. I'm curious though as to why my first line doesn't work and if there is a way to get it to work without having to loop through every single result and manually build my array.
Thanks!
The
filter
method only applies a filter, it does not fetch data. TheforEach
method fetches data and applies the callback to it. If you want to fetch the data after applying a filter, callfetch
:If you are using a synchronous store (
dstore/Memory
) thefetchSync
method is available: