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>
<button onclick="clearCustomizing()">Clear Customizing</button>
<button onclick="startCustomizing()">Start Customizing</button>
<div id="pivot-container"></div>
CSS
.error-cell {
background-color: #FFB74D !important;
}
/********************* Styles for the description *********************/
h2 {
text-align: center;
}
p {
font-size: 15px;
line-height: 1.5;
padding-right: 10px;
padding-left: 10px;
}
a {
color: #00a45a;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
code {
font-size: 105%;
color: #DF3800;
background-color: #f5f5f5;
padding: 1px 4px;
font-family: monospace !important;
border-radius: 4px;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
customizeCell: customizeCellFunction,
toolbar: true,
report: {
dataSource: {
data: getData()
},
options: {
grid: {
type: "flat"
}
}
}
});
let invalidRowIndex;
function customizeCellFunction(cell, data) {
if(data.label == "invalid") {
cell.addClass('error-cell');
invalidRowIndex = data.rowIndex;
}
if(data.rowIndex == invalidRowIndex && data.member && data.member.caption == "red") {
cell.addClass('error-cell');
}
}
function clearCustomizing() {
pivot.customizeCell(null);
}
function startCustomizing() {
pivot.customizeCell(customizeCellFunction);
}
function getData() {
return [{
"status": "valid",
"color": "green",
"price": 10
},
{
"status": "invalid",
"color": "red",
"price": 12
},{
"status": "invalid",
"color": "red",
"price": 12
},{
"status": "valid",
"color": "green",
"price": 12
},
]
}