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 pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
beforetoolbarcreated: customizeToolbar,
report: {
dataSource: {
filename: "data/data.json"
}
}
});
function customizeToolbar(toolbar) {
toolbar.getTabs = function() {
let tabs = [];
tabs.unshift({
id: "fm-tab-newtab",
title: "Set Report",
menu: [{
id: "fm-tab-one",
title: "Report one",
handler: handlerOne
},
{
id: "fm-tab-two",
title: "Report two",
handler: handlerTwo
},
{
id: "fm-tab-three",
title: "Report three",
handler: handlerThree
}
],
icon: this.icons.open
});
return tabs;
}
let handlerOne = () => {
setReport("fr");
}
let handlerTwo = () => {
setReport("uk");
}
let handlerThree = () => {
setReport("es");
}
}
function setReport(lang) {
let report = {
dataSource: {
filename: "data/data-" + lang + ".csv"
}
}
flexmonster.setReport(report);
}