Reputation: 137
I have an issue trying to filter the results of an association. I have a list of categories with many subcategories. I'm using MVC architecture. So, here is an example what I'm trying to do:
var subcategories = category.subcategories();
subcategories.filter("title", "some text");
subcategories.each( function (item) { console.log(item.get('title')); } );
Some how the filter is not applying. It always return the original store, same amount of records, etc.
I'm also doing this:
var subcategories = category.subcategories();
subcategories.filterBy(function(item) {
console.log( item );
return (item.get('title') == 'some text');
});
But the console.log it's not running even once! The store is full of records, I've cehcked that
Any ideas? Am I doing something wrong? Thanks
Upvotes: 2
Views: 592
Reputation: 3211
This may be a late answer, but it will help many people who are searching solution for the same problem.
The key is to calling setRemoteFilter(false)
on Association's Store.
var products = user.products();
products.setRemoteFilter(false); // without this line, filter on Association's Store didn't work
var categorieFilter = new Ext.util.Filter({
property: 'categories',
value : 'Electronic'
});
products.setFilters(categorieFilter);
Upvotes: 1
Reputation: 17860
Couple questions:
What version of Sencha Touch are you using?
When using associations in Sencha Touch you still need to do a lot of work by yourself. It's not completely automatic. For example you need to add all subcatagories manually to each category object. Are you doing this?
Upvotes: 1