JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivotContainer"></div>
CSS
.link {
text-decoration: underline !important;
}
JavaScript
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
cellclick: (data) => {
if (
data.hierarchy &&
data.hierarchy.uniqueName == "Cases per year" &&
data.type == "value" &&
!data.isGrandTotal
) {
window.open(data.recordId);
}
},
report: {
dataSource: {
data: getData(),
mapping: {
Country: {
type: "string",
},
"Cases per year": {
type: "number",
},
Link: {
type: "id",
},
},
},
options: {
grid: {
type: "flat",
},
},
},
});
flexmonster.customizeCell((cell, data) => {
if (
data.hierarchy &&
data.hierarchy.uniqueName == "Cases per year" &&
data.type == "value" &&
!data.isGrandTotal
) {
cell.text = `<span class="link">${cell.text}</span>`;
}
});
function getData() {
return [
{
Country: "Australia",
"Cases per year": 8756,
Link: "https://en.wikipedia.org/wiki/Australia",
},
{
Country: "USA",
"Cases per year": 3578,
Link: "https://en.wikipedia.org/wiki/United_States",
},
{
Country: "Germany",
"Cases per year": 2953,
Link: "https://en.wikipedia.org/wiki/Germany",
},
{
Country: "Germany",
"Cases per year": 2953,
Link: "https://en.wikipedia.org/wiki/Germany",
},
{
Country: "Germany",
"Cases per year": 2953,
Link: "https://en.wikipedia.org/wiki/Germany",
},
{
Country: "Germany",
"Cases per year": 2953,
Link: "https://en.wikipedia.org/wiki/Germany",
},
{
Country: "Germany",
"Cases per year": 2953,
Link: "https://en.wikipedia.org/wiki/Germany",
},
{
Country: "Germany",
"Cases per year": 2953,
Link:...