Results 1 to 5 of 5

Thread: Count store records with condition

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    23
    Vote Rating
    1
      0  

    Default Answered: Count store records with condition

    Is there a way to conitionally count the records of a store, ie. those records that have a specific value in a given field?

  2. You could use:

    Code:
    store.each(function(record) {
       // condition
    });
    Scott.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716
    Vote Rating
    504
      1  

    Default

    You could use:

    Code:
    store.each(function(record) {
       // condition
    });
    Scott.

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    23
    Vote Rating
    1
      0  

    Default

    thanks. that's what i did.

    Code:
    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.

  5. #4
    Sencha User
    Join Date
    Feb 2013
    Posts
    25
    Vote Rating
    0
      0  

    Default

    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

  6. #5
    Sencha User
    Join Date
    Dec 2016
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by bikrems View Post
    Hi KostasP

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

    Thanx and waiting for your reply
    You can use this anywhere you have access to Ext.
    Define the store using
    Code:
    store = Ext.getStore('yourstoreid')

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •