Search code examples
javascriptextjssencha-touch

how to get total records with a previous filter in a Sencha Touch app?


Working with an application based in Sencha Touch I need to get total amount of a store but with a previous filter implemented.

I can do store.getCount() and to know the total records of a store, but How to know total records with a previous filter?


Solution

  • Here is an alternative solution :

    var count = 0;
    
    store.findBy(function(rec) {
        if (rec.get('myFilter')) {
            count++; // Only counting matching data
        }
    });
    
    console.log(count); // Total amount of filtered data
    

    From : https://www.sencha.com/forum/showthread.php?174156-Store-count-by-criteria-without-filter