JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
type: "json",
data: getData(),
mapping: {
"Category": {
type: "string"
},
"Size": {
type: "string"
},
"Color": {
type: "string"
},
"Destination": {
type: "string"
},
"Business Type": {
type: "string"
},
"Country": {
type: "string"
},
"Price": {
type: "number"
},
"Quantity": {
type: "number"
},
"Discount": {
type: "number"
},
"Spacer": {
type: "number",
filters: false,
caption: "spacer",
aggregations: ["sum"]
},
}
},
"slice": {
"rows": [{
"uniqueName": "Category"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
},
{
"uniqueName": "Spacer"
},
{
"uniqueName": "Quantity",
"aggregation": "sum"
}
]
}
},
width: "100%",
height: 370
});
//Set the "Spacer" field values to "":
pivot.customizeCell((cell, data)=>{
if(data && (data.measure && data.measure.uniqueName == "Spacer") || (data.hierarchy && data.hierarchy.uniqueName == "Spacer") ){
cell.text = "";
}
})
//Disable the context menu for the "Spacer" field:
pivot.customizeContextMenu((items, data, viewType) => {
if(data && (data.measure && data.measure.uniqueName == "Spacer") || (data.hierarchy && data.hierarchy.uniqueName == "Spacer") ){
return [];
}
});
function getData() {
return [{
"Category": "Accessories",
"Size": "262 oz",
"Color": "red",
"Destination":...