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>
<div class="output" id="output">Output will appear here</div>
CSS
.output {
width: 80%;
height: 300px;
margin-left: auto;
margin-right: auto;
padding: 20px;
background: rgba(242, 242, 242, 1);
font-family: Menlo, Monaco, "Courier New", Courier, monospace;
white-space: pre;
font-size: 16px;
font-weight: 400;
overflow-y: scroll;
margin-top: 20px;
}
JavaScript
let pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
Identifier: {
type: "id"
}
}
},
options: {
drillThrough: false
}
}
});
flexmonster.on("celldoubleclick", data => {
let output = "";
if (!data.recordId) output += "No records assosiated with the clicked cell";
else {
output += `Identifiers: ${data.recordId}\n`;
let records = getData().filter(record => data.recordId.includes(record.Identifier));
output += `Records:\n${JSON.stringify(records, null, 4)}`;
}
showOutput(output);
});
function getData() {
return [{
"Category": "Accessories",
"Size": "262 oz",
"Color": "red",
"Destination": "Australia",
"Business Type": "Specialty Bike Shop",
"Country": "Australia",
"Price": 174,
"Quantity": 225,
"Discount": 23,
"Identifier": 0
},
{
"Category": "Accessories",
"Size": "214 oz",
"Color": "yellow",
"Destination": "Canada",
"Business Type": "Specialty Bike Shop",
"Country": "Canada",
"Price": 502,
"Quantity": 90,
"Discount": 17,
"Identifier": 1
},
{
"Category": "Clothing",
"Size": "112 oz",
"Color": "blue",
"Destination": "Australia",
"Business Type": "Specialty Bike Shop",
"Country": "Germany",
"Price": 535,
"Quantity": 9996,
"Discount": 3,
"Identifier": 2
},
{
"Category": "Clothing",
"Size": "292 oz",
"Color": "white",
"Destination": "Canada",
"Business Type": "Specialty Bike Shop",
"Country": "United Kingdom",
"Price": 12,
"Quantity": 3128,
"Discount": 52,
"Identifier": 3
},
{
"Category": "Components",
"Size": "76 oz",
"Color": "red",
"Destination": "United...