JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
May 12, 2020
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button onclick="showTotal()">Show Grand Total For Discount</button>
<button onclick="hideTotal()">Hide Grand Total For Discount</button>
<div id="pivot-container"></div>
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 600,
toolbar: true,
customizeCell: customizeCellFunction,
report: {
"dataSource": {
"type": "json",
"filename": "https://cdn.flexmonster.com/data/data.json"
},
"slice": {
"rows": [{
"uniqueName": "Category"
}],
"columns": [{
"uniqueName": "Color"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
},
{
"uniqueName": "Discount",
"aggregation": "sum"
},
{
"uniqueName": "Quantity",
"aggregation": "sum"
}
]
}
}
});
function customizeCellFunction(cell, data) {
if (data && data.isGrandTotal && data.type == "value" && data.measure && data.measure.uniqueName == "Discount") {
console.log(data);
cell.text = "";
}
}
function showTotal() {
pivot.customizeCell(null);
}
function hideTotal() {
pivot.customizeCell(customizeCellFunction);
}