View Full Version : Min/Max/Avg in a store

26 Jun 2010, 5:55 AM

I am updating periodically a jsonstore and I'd like to print to the user min, max and avg value in realtime (in a status bar for example).
What is the best way to do ? decode each value received before sending to the store (loaddata) ? Do a query on the store ? Is there any API to get min/max and so on ?

Thx a lot.

26 Jun 2010, 6:51 AM

You can use that, and then using that method's source, add some overrides to do the other calcs in the same way.

26 Jun 2010, 7:08 AM
Hello Animal,

Thank you for the sum example.
In my case (because values are always > 0):

var rs = store.data.items, v = 0;
var end = rs.length-1;

for(var i = 0; i <= end; i++){
if (rs[i].data[property] > v) {
v = rs[i].data[property];