JSFiddle - React, Tailwind, and code Playground
Number formatting
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
CSS
@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);
JavaScript
const PRECISION = 2;
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
customizeCell: customizeCellFunction,
report: {
dataSource: {
data: getData(),
},
},
});
function getData() {
return [
{
Color: "red",
Price: 999.5678,
},
];
}
function customizeCellFunction(cell, data) {
if (data.type === "value" && Number.isFinite(data.value)) {
cell.text = parseFloat(Number(data.value).toFixed(PRECISION));
}
}