Retrieve Filtered Data from a DataCollection

How does one get filtered data from a DataCollection.

For instance, in the book store example app, if i wanted to get all the books in a certain genre and return this as an array of js objs rather than bind it to a component?

collection.filter("#genre#", "Detective"); var result = []; collection.data.each(function(obj){ result.push(obj); });

now you have in result set of objects, filtered by defined criteria

Tks. That works.

More info on filtration here for those interested:
docs.dhtmlx.com/touch/doku.php?i … ter_data&s[]=filter

So it looks like if you run the code above twice, the second time you don’t get any records back?

This seems a little inflexible if gonna be filtering multiple times. Is there a better way? Would be nice to be able to do something like:

filteredObjs = collection.filter(filterCriteria)

So it looks like if you run the code above twice
Actually you can run the filter as many times as necessary.
But each time it will filter against original dataset, not against the result of previous filtering.

To unfilter data and return collection to initial state you can call

collection.filter();//without parameters

Also you can try to use

collection.filter("#genre#", "Detective"); var result = collection.serialize();

Last one works and most concise.