Formatting Numbers in Custom Statistics Counters

I have a grid that I load using .load(…“xmlB”), with three headers. The first header is simply labels. The second header is a total of the values in that column, using:


The third header is that subtotal, plus a constant. I created a custom statistic counter named stat_sum_const1, as follows:


with script that is based on the sample code:

mygrid._in_header_stat_sum_krd30=function(tag,index,c){ // shortcut for statistics counter var calck=function(){ // define the function which will be used for calculations var summ=1234567; // set initial counter value this.forEachRow(function(id){ // for each row summ+=this.cells(id,index).getValue()*1; // add row_value }) return summ; } this._stat_in_header(tag,calck,index,c); //call default statistics handler processor }

In this case, I add 1,234,567 to the total. Then, lastly, I format the column with a thousands separator.


So the totals all work correctly, and the math in my custom addition works too, but the header that uses the standard #stat_total has comma separators, but the #stat_sum_const1 header does not (and has decimals going out much further).

Does anybody know why I get this behavior, and if there is anything I can do to get the formatting of the custom statistic counter to format correctly? Thanks

In your custom function you are returning the summ:
return summ;

In the stat_total counter

[code] var calck=function(){
var summ=0;
var ii = this._m_order?this._m_order[i]:i;
for (var j=0; j<this.rowsBuffer.length; j++){
var v=parseFloat(this._get_cell_value(this.rowsBuffer[j],ii));

	return this._maskArr[ii]?this._aplNF(summ,ii):(Math.round(summ*100)/100);

it’s returning the formatted number:

return this._maskArr[ii]?this._aplNF(summ,ii):(Math.round(summ*100)/100);