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
.link {
text-decoration: underline !important;
cursor: pointer;
color: #726b04 !important;
}
JavaScript
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
Country: {
type: "string"
},
CountryId: {
type: "id"
},
Year: {
type: "string"
},
Cases: {
type: "number"
}
}
},
"slice": {
"rows": [{
"uniqueName": "Country"
}],
"columns": [{
"uniqueName": "Year"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "Cases",
"aggregation": "sum"
}]
}
}
});
let urlList = {
"1": "https://en.wikipedia.org/wiki/Mexico",
"2": "https://es.wikipedia.org/wiki/M%C3%A9xico",
"3": "https://en.wikipedia.org/wiki/Egypt",
"4": "https://arz.wikipedia.org/wiki/%D9%85%D8%B5%D8%B1",
"5": "https://en.wikipedia.org/wiki/Canada",
"6": "https://fr.wikipedia.org/wiki/Canada"
}
flexmonster.customizeCell((cell, data) => {
if (data.isDrillThrough && data.type != "header" && data.hierarchy && data.hierarchy.uniqueName == "Country") {
cell.style['z-index'] = 1;
cell.text = `<a href="${urlList[data.recordId]}" class='link' onclick='preventExpand(event)'>${data.label}</a>, id: ${data.recordId}`;
}
});
function preventExpand(e) {
e.stopImmediatePropagation();
}
function getData() {
return [{
"Country": "Mexico",
"CountryId": 1,
"Year": 2019,
"Cases": 54
},
{
"Country": "Mexico",
"CountryId": 2,
"Year": 2020,
"Cases": 65
},
{
"Country": "Egypt",
"CountryId": 3,
"Year": 2018,
"Cases": 63
},
{
"Country": "Egypt",
"CountryId": 4,
"Year": 2020,
"Cases": 57
},
{
"Country": "Canada",
"CountryId": 5,
"Year": 2018,
"Cases": 52
},
{
"Country":...