PDA

View Full Version : max value of a store numeric column



SpinoWeb
19 Mar 2011, 5:33 AM
I'd want to calculate the max value of a column in my json store:

var maxId = Math.max(myStore.findColumnIndex('id'));
it doesn't work.

How can do it?

thanks!

fay
19 Mar 2011, 5:52 AM
Something like:



if (myStore.getCount() > 0)
{
var maxId = myStore.getAt(0).get('id'); // initialise to the first record's id value.
myStore.each(function(rec) // go through all the records
{
maxId = Math.max(maxId, rec.get('id'));
});
}

SpinoWeb
19 Mar 2011, 6:21 AM
it works! Thank you!