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="pivot-container"></div>
CSS
.link {
text-decoration: underline !important;
cursor: pointer;
color: #00a45a !important;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
customizeCell: customizeCellFunction,
report: {
dataSource: {
filename: "data/data.json"
},
options: {
grid: {
type: "flat"
}
},
slice: {
rows: [{
uniqueName: "Country"
}, {
uniqueName: "Color"
}],
columns: [{
uniqueName: "Category",
filter: {
exclude: ["Accessories"]
}
}, {
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Price"
}]
}
}
});
function customizeCellFunction(cell, data) {
if (!(data.hierarchy && data.hierarchy.uniqueName == "Country")) return;
let newText =
`<a href='https://en.wikipedia.org/wiki/${data.escapedLabel}' target='_blank' class='link' onclick='preventExpand(event)'>${data.escapedLabel}</a>`;
if (data.type == "header" && data.member) {
let parts = cell.text.split(data.escapedLabel);
if (parts.length == 2) {
newText = parts[0] + newText + parts[1];
}
cell.text = newText;
} else if (data.type == "value" && (data.member || data.isDrillThrough)) {
//notice the z-index added to the cell with link
cell.style['z-index'] = 1;
cell.text = newText;
}
}