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 PDF 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) {
      console.log("here")
      let exportToPdfTab = exportTab.menu.find(
        (tab) => tab.id == "fm-tab-export-pdf",
      )
      exportToPdfTab.handler = exportToPDFHandler
    }
    return tabs
  }
}

function exportToPDFHandler() {
  console.log("your custom functionality before exporting")
  pivot.exportTo("pdf", {
    header: "<div>HEADER</div>",
    footer: "<div>##CURRENT-DATE##</div>",
  })
}