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>
  <h2>How to customize the dropdown menu of a Toolbar tab</h2>
  <p>
  You can customize the dropdown menu of a Toolbar tab with the <code>beforetoolbarcreated</code> event. In its handler, use the tab's <code>menu</code> property to manage the dropdown menu items.</p>
  <p>
  In this example, we've added the <strong>Sales Report</strong> item to the <strong>Open</strong> tab. Click this menu item to open a predefined report. 
  </p>
  <p><a href="https://www.flexmonster.com/doc/customizing-toolbar/" target="_blank">For more examples of Toolbar customization, see our documentation</a>.
  </p>
</div>

<div id="pivot-container"></div>

CSS

h2 {
  text-align: center;
}

p {
  font-size: 15px;
  line-height: 1.5;
  padding-right: 10px;
  padding-left: 10px;
}

a {
  color: #00a45a;
}

code {
    font-size: 105%;
    color: #DF3800;
    background-color: #f5f5f5;
    padding: 1px 4px;
    font-family: monospace !important;
    border-radius: 4px;
}

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  beforetoolbarcreated: customizeToolbar
});

function customizeToolbar(toolbar) {
	let tabs = toolbar.getTabs();
  toolbar.getTabs = function() {
    let connectTab = tabs.find(tab => tab.id == "fm-tab-connect");
    connectTab.menu.unshift({
    	id: "fm-tab-connect-fds",
      title: "To FDS",
      handler: () => {
        pivot.connectTo({
      "type": "api",
      "url": "https://olap.flexmonster.com:9500",
      "index": "fm-product-sales"
    })
      },
      icon: this.icons.open_remote
    });
    return tabs;
  }
}