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="pivotContainer"></div>
CSS
#pivotContainer a[data-h="0"] {
visibility: hidden;
float: right !important;
}
JavaScript
const dummyFieldName = "$Dummy$";
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
"Color": {
"type": "string"
},
"Month": {
"type": "month"
},
"Week Day": {
"type": "weekday"
},
"Price": {
"type": "number"
},
"Quantity": {
"type": "number"
},
[dummyFieldName]: { }
}
},
"slice": {
"reportFilters": [{
"uniqueName": dummyFieldName
}],
"rows": [{
"uniqueName": "Color"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
}]
}
}
});
pivot.on("fieldslistopen", function() {
pivot.off("fieldslistopen");
let lists = document.querySelectorAll("#pivotContainer div.fm-ui-element.fm-ui.fm-list-content > ul");
const sheet = new CSSStyleSheet();
setTimeout(() => {
for (let node of lists[0].childNodes)
if (node.childNodes[1].innerText == dummyFieldName)
sheet.insertRule(`${getUniqueSelector(node)} { display: none !important; }`);
for (let node of lists[1].childNodes)
if (node.childNodes[0].innerText == dummyFieldName)
sheet.insertRule(`${getUniqueSelector(node)} { display: none !important; }`);
});
document.adoptedStyleSheets = [sheet];
});
function getUniqueSelector(node) {
let selector = "";
while (node.parentElement) {
const siblings = Array.from(node.parentElement.children).filter(
sibling => sibling.tagName === node.tagName
);
let attributes = "";
for (let attribute of node.attributes)
if (attribute.name != "id")
attributes += `[${attribute.name}="${attribute.value}"]`;
selector = (siblings.indexOf(node) ?
...