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
new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 550,
toolbar: true,
customizeCell: customizeCellFunction,
report: {
dataSource: {
type: "json",
data: [{
firstName: "name1",
lastName: "surname1",
salary: 90000,
birthDate: "2020-12-31",
terminated: false,
},
{
firstName: "name2",
lastName: "surname2",
salary: 80000,
birthDate: "2020-11-31",
terminated: true,
}
]
},
slice: {
rows: [{
"uniqueName": "firstName"
},
{
"uniqueName": "terminated"
},
{
"uniqueName": "terminatedPretty"
}
],
columns: [{
"uniqueName": "[Measures]"
}],
flatOrder: [
"firstName",
"terminated",
"terminatedPretty"
]
},
options: {
grid: {
type: "flat"
}
}
}
})
function customizeCellFunction(cell, data) {
if (data.type == "value" && data.hierarchy.uniqueName == "terminated") {
if (data.label == "false") {
cell.text = "No"
} else if (data.label == "true") {
cell.text = "Yes"
}
}
}