PDA

View Full Version : [3.2.0][3.1.1] GroupSummary



maquejp
22 Apr 2010, 1:43 AM
I have a strange behavior with one of my column (Sum)
21 lines with 3 that have values 0.27+0.33+0.13 should gives 0.73 but gives 0.7300000000000001.
The column before is doing the same (Sum) but gives the right sum with his related value.

I checked by changing the grouping column and it gives the same behavior.

I tested with 3.2.0 and 3.1.1

Is it a (known) bug?

edspencer
23 Apr 2010, 3:56 PM
Is it a (known) bug?

Not with Ext JS - this is a JavaScript number implementation artifact. You'll have to run it through Math.round to get a rounded integer out of it.

Stormseeker
23 Apr 2010, 9:16 PM
I use Ext.util.Format.round(number, precision)... Is that overkill or is that what you meant?

edspencer
24 Apr 2010, 12:49 AM
That's fine, as is vanilla Math.round

maquejp
26 Apr 2010, 5:26 AM
Not with Ext JS - this is a JavaScript number implementation artifact. You'll have to run it through Math.round to get a rounded integer out of it.
Never heard about this JavaScript way to manage the addition of decimal number...
So I have to extend or modify the UX adding the Math.Round() on the sum function...


calculate : function(rs, cs){
var data = {}, r, c, cfg = this.grid.getColumnModel().config, cf;
for(var j = 0, jlen = rs.length; j < jlen; j++){
r = rs[j];
for(var i = 0, len = cs.length; i < len; i++){
c = cs[i];
cf = cfg[i];
if(cf.summaryType){
data[c.name] = Math.round(Ext.ux.grid.GroupSummary.Calculations[cf.summaryType](data[c.name] || 0, r, c.name, data)*100)/100;
}
}
}
return data;
},