|
[app.component.ts]
export class AppComponent {
public data: Object[] = [
{ OrderID: 10248, Freight: 11 },
{ OrderID: 10249, Freight: 1000000000000000000000 },
{ OrderID: 10250, Freight: 144623000000000000000000 }
];
ngOnInit(): void {}
queryCellInfo(args) {
if (args.column.field == "Freight") {
// customize the innertext of cell as you want
args.cell.innerText = "$" + this.toFixed(args.data[args.column.field]) + ".00";
}
}
// this method is used to avoid scientific notation and return the value as you want
toFixed(x) {
if (Math.abs(x) < 1.0) {
var e = parseInt(x.toString().split("e-")[1]);
if (e) {
x *= Math.pow(10, e - 1);
x = "0." + new Array(e).join("0") + x.toString().substring(2);
}
} else {
var e = parseInt(x.toString().split("+")[1]);
if (e > 20) {
e -= 20;
x /= Math.pow(10, e);
x += new Array(e + 1).join("0");
}
}
return x;
}
}
|