<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div>
<h2>How to add a custom tab to the Toolbar</h2>
<p>
You can add a new tab to the Toolbar using the
<code>beforetoolbarcreated</code> event. In the event handler, define a
custom tab with a needed functionality and add it to the array of Toolbar
tabs. We've added the <strong>New Tab</strong> in this example (lines 14-24
in the JavaScript box).
</p>
<p>
With the <code>beforetoolbarcreated</code> event, you can also remove or
update existing Toolbar tabs.
</p>
<p>
<a
href="https://www.flexmonster.com/doc/customizing-toolbar/"
target="_blank"
>Refer to our docs to learn more about customizing the Toolbar</a
>.
</p>
</div>
<div id="pivot-container"></div>
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
height: 400,
toolbar: true,
beforetoolbarcreated: customizeToolbar,
report: {
dataSource: {
filename: "data/data.json"
}
}
});
function customizeToolbar(toolbar) {
let tabs = toolbar.getTabs();
toolbar.getTabs = function() {
tabs.unshift({
// An attribute that is used for CSS styling
id: "fm-tab-newtab",
// The tab’s label
title: "New Tab",
// A function that handles clicks on this tab
handler: newtabHandler,
// An HTML element with a tab icon
// You can choose an icon defined in flexmonster.toolbar.js
icon: this.icons.open
});
return tabs;
}
let newtabHandler = () => {
alert("New functionality!");
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.