JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
JavaScript
let iconUrl = "https://static.thenounproject.com/png/3479317-200.png";
let href = "https://www.flexmonster.com/api/customizecell/";
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
customizeCell: customizeCellFunction,
report: {
options: {
grid: {
type: "flat"
},
showGrandTotals: false
},
dataSource: {
data: [{
"Category": "Accessories",
"Material": "silver",
"Quantity": 100
}]
}
}
});
function customizeCellFunction(cell, data) {
if (data.label === "Accessories") {
/*z-index is needed to make icon clickable*/
cell.style["z-index"] = 2;
cell.text = `<a href="${href}" target="_blank"> <img width="20" src="${iconUrl}"/></a>`
}
}