JSFiddle - React, Tailwind, and code Playground
Customizing the Toolbar
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>
<h3>
Try exporting to Excel using the "Export" tab
</h3>
<div id="pivot-container"></div>
JavaScript
const pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
beforetoolbarcreated: customizeToolbar,
report: "https://cdn.flexmonster.com/reports/report.json"
});
function customizeToolbar(toolbar) {
let tabs = toolbar.getTabs();
toolbar.getTabs = function() {
let exportTab = tabs.find(tab => tab.id == "fm-tab-export");
if (!exportTab) return tabs;
let exportToPdfTab = exportTab.menu.find(tab => tab.id == "fm-tab-export-excel");
exportToPdfTab.handler = () => {
this.pivot.exportTo("excel", {
destinationType: "plain"
}, (result)=>{
console.log('Exporting to Excel with destinationType: "plain"',result)
//TODO: Modify and save the Excel file
});
}
return tabs;
}
}