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>
<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;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
code {
font-size: 105%;
color: #DF3800;
background-color: #f5f5f5;
padding: 1px 4px;
font-family: monospace !important;
border-radius: 4px;
}
ol.styledList {
list-style: none;
counter-reset: item;
font-size: 15px;
line-height: 1.5;
padding-left: 25px;
}
ol.styledList > li::before {
content: counter(item);
counter-increment: item;
display: block;
font-weight: bold;
color: #df3800;
position: absolute;
margin: 0;
margin-left: 9px;
left: 0;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
height: 400,
global: {
localization: "loc/es.json",
},
report: {
dataSource: {
filename: "data/data.csv",
},
localization: {
toolbar: {
formatNumbers: "Custom",
},
},
},
beforetoolbarcreated: customizeToolbar,
})
function customizeToolbar(toolbar) {
let tabs = toolbar.getTabs()
toolbar.getTabs = function () {
tabs.unshift({
id: "fm-tab-format-cells",
title: this.Labels.formatNumbers,
handler: this.formatCellsHandler,
icon: this.icons.format_number,
})
return tabs
}
toolbar.updateLabels = function (labels) {
FlexmonsterToolbar.prototype.updateLabels.call(this, labels)
this.setText(
document.querySelector("#fm-tab-format-cells > a > span"),
this.Labels.formatNumbers,
)
}
}