Manage visibility of totals
Options
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button onclick="turnOnTotals()">Turn on totals</button>
<button onclick="turnOffTotals()">Turn off totals</button>
<button onclick="totalsInRows()">Show totals in rows</button>
<button onclick="totalsInColumns()">Show totals in columns</button>
<div id="pivot-container"></div>
CSS
@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);
#fm-pivot-view .fm-grid-layout .fm-total:not(.fm-header, .fm-grand-total) {
background-color: #edfae3 !important;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
height: 600,
report: {
dataSource: {
filename: "https://cdn.flexmonster.com/data/data.csv",
type: "csv",
},
slice: {
columns: [
{
filter: {
members: ["color.[red]", "color.[green]", "color.[blue]"],
},
uniqueName: "Color",
},
{
filter: {
members: ["category.[bikes]", "category.[cars]"],
},
uniqueName: "Category",
},
{
uniqueName: "[Measures]",
},
],
expandAll: true,
measures: [
{
aggregation: "sum",
format: "currency",
uniqueName: "Price",
},
],
rows: [
{
filter: {
members: [
"country.[canada]",
"country.[germany]",
"country.[united kingdom]",
],
},
uniqueName: "Country",
},
{
uniqueName: "Business Type",
},
],
},
version: "2.9.109",
},
});
function turnOffTotals() {
let options = pivot.getOptions();
options.grid.showTotals = "off";
pivot.setOptions(options);
pivot.refresh();
}
function turnOnTotals() {
let options = pivot.getOptions();
options.grid.showTotals = "on";
pivot.setOptions(options);
pivot.refresh();
}
function totalsInRows() {
let options = pivot.getOptions();
options.grid.showTotals = "rows";
pivot.setOptions(options);
pivot.refresh();
}
function totalsInColumns() {
let options = pivot.getOptions();
options.grid.showTotals = "columns";
pivot.setOptions(options);
pivot.refresh();
}