View Full Version : Count store records with condition

31 Jul 2012, 11:09 AM
Is there a way to conitionally count the records of a store, ie. those records that have a specific value in a given field?

31 Jul 2012, 11:19 AM
You could use:

store.each(function(record) {
// condition


31 Jul 2012, 11:37 AM
thanks. that's what i did.

var evts=0; var rprs=0;
store.each(function(record) {
var rep = record.get('EvtRepaired');
if(rep==0 || !rep || rep=="") {
if(record.get('EvtRprID')) rprs+=1;
else evts+=1;

by the way, for anyone who finds this thread if u are using a remote api store put the code in a store load callback cause the onLaunch function of the controller is not late enough for the store to be ready and loaded.

13 Mar 2013, 6:08 PM
Hi KostasP

I have one doubt...Where did you put the code i.e in store or somewhere else???

Thanx and waiting for your reply