The Toolbar is an HTML/JS addition to Flexmonster. It uses a standard API and provides easy access to the most commonly used features. The Toolbar is free and provided “as is”.
The Toolbar is available since version 2.0. Enabling the Toolbar is very easy, just set the toolbar
parameter in the new Flexmonster()
function call to true
.
new Flexmonster({ container:String, componentFolder:String, global:Object, width:Number, height:Number, report:Object, toolbar:Boolean, licenseKey:String})
Ensure that your flexmonster/
folder includes the toolbar/
folder and that it’s not empty.
Use flexmonster.toolbar
to get a reference to the Toolbar instance. It allows calling its functions on the page from outside of the pivot table.
The Toolbar can be customized using the beforetoolbarcreated event. Tabs and buttons can be removed from it and new ones can be easily added.
Add a beforetoolbarcreated
event handler. Inside the handler you can get all tabs using the getTabs()
method that returns an Array
of Objects
, each of which describes a tab. To remove a tab just delete the corresponding Object
from the Array
. The following example will remove the first tab:
new Flexmonster({ container: "pivotContainer", toolbar: true, licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX", beforetoolbarcreated: customizeToolbar }); function customizeToolbar(toolbar) { // get all tabs var tabs = toolbar.getTabs(); toolbar.getTabs = function () { // delete the first tab delete tabs[0]; return tabs; } }
Open the example on JSFiddle.
The following code will add a new tab:
new Flexmonster({ container: "pivotContainer", toolbar: true, licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX", beforetoolbarcreated: customizeToolbar }); function customizeToolbar(toolbar) { // get all tabs var tabs = toolbar.getTabs(); toolbar.getTabs = function () { // add new tab tabs.unshift({ id: "fm-tab-newtab", title: "New Tab", handler: newtabHandler, icon: this.icons.open }); return tabs; } var newtabHandler = function() { // add new functionality } }
where:
title
– String. The label of the tab.
id
– String. The id used in CSS styles.
handler
– String. The name of the function that handles clicks on this tab.
icon
– String. The HTML tag containing your custom icon for this new tab. You can choose one of the basic vector icons defined in the flexmonster.toolbar.js
file.There are also some optional parameters:
args
– Any. The argument to pass to the handler.
menu
– Array. The dropdown menu items.
mobile
– Boolean. If false
– doesn’t appear on mobile devices.
ios
– Boolean. If false
– doesn’t appear on iOS devices.
android
– Boolean. If false
– doesn’t appear on Android devices.
Check out an example of creating a new tab on JSFiddle.
You can customize almost everything. To explore all the options we recommend investigating the existing code. Look in the toolbar/
folder (you can find it in [package]/flexmonster/
). Open the flexmonster.toolbar.js
file. Find the tab section (it starts with the getTabs()
function expression) to understand how it works.
To change the appearance of the Toolbar read customizing appearance.