I am using the following Column Formater from the guide
$col = array();
$col[“name”] = “Margin”;
$col[“formatter”] = “function(cellval,options,rowdata){ return cellval*100+’%’; }”;
$col[“unformat”] = “function(cellval,options,cell){ return cellval.replace(‘%’,”)/100; }”;
$cols[] = $col;
The percentage values I am getting are like “39.253121532461322214%”
I have tried to use round(), but the grid just shows “loading…” and never does. C
Can you advise?
1 Answers
Hello,
This is JS code so you need to use Math.round(value, precision)
$col[“formatter”] = “function(cellval,options,rowdata){ return Math.round(cellval*100,2)+’%’; }”;
Bah, makes sense. Thanks for the swift response.
Your Answer