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>
JavaScript
const customizeCell = (cell, data) => {
const hierarchy = data.hierarchy;
if (hierarchy && data.label) {
if (data.type === 'value') {
if (hierarchy.caption === "Supplier Name") {
var id = JSON.parse(data.recordId);
cell.text = `<a href="/` + id.id + `/`+ id.parentId + `">${data.label}</a>`;
}
}
}
}
const pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
report: {
dataSource: {
dataSourceType: "json",
data: getData()
},
options: {
grid: {
type: 'flat'
},
}
},
width: "100%",
height: 370,
customizeCell: customizeCell,
});
function getData() {
return [{
0: {
type: "id"
},
1: {
caption: "Supplier Name",
type: "string"
},
2: {
caption: "Profit",
type: "number"
}
},
[JSON.stringify({
id: 1,
parentId: 22
}), "Foo Bars", 123.4],
[JSON.stringify({
id: 2,
parentId: 22
}), "Foo Bars Extra", 420.00]
];
}