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="applyReportFilter()">
SEE FILTER EXAMPLE
</button>
<div id="pivot-container"></div>
CSS
.fm-custom-cell {
display: flex !important;
align-items: center !important;
font-size: 12px !important;
}
.fm-custom-cell .flag-icon {
width: 21px !important;
height: 16px !important;
margin-left: 0 !important;
margin-right: 2px !important;
}
#fm-pivot-view .fm-grid-layout .fm-custom-cell.fm-expanded .fm-expanded-icon::before,
#fm-pivot-view .fm-grid-layout .fm-custom-cell.fm-collapsed .fm-collapsed-icon::before {
top: -2px;
height: 16px;
}
JavaScript
var flex = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
toolbar: true,
report: {
"dataSource": {
"type": "json",
"filename": "https://cdn.flexmonster.com/data/retail-data.json",
"mapping": {
"Price": {
"type": "number"
},
"Sales": {
"type": "number"
},
"Order Date": {
"type": "year/quarter/month/day"
},
"Status": {
"type": "string"
},
"Country": {
"type": "string",
"folder": "Location"
}
}
},
"slice": {
"rows": [
{
"uniqueName": "Status",
}
],
"columns": [{
"uniqueName": "Order Date"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum",
"format": "-13w0a1w1c23j00"
}]
}
}
});
/*
Here is the example of adding a new Report Filter.
*/
function applyReportFilter() {
let report = flex.getReport();
report.slice.reportFilters = [{
"uniqueName": "Country",
"filter": {
"members": [
"country.[australia]"
]}
}];
flex.runQuery(report.slice);
}