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>

<button onclick="hideTotals()">Hide total row</button>
<button onclick="showTotals()">Show total row</button>

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

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    slice: {
      rows: [{
        uniqueName: "Category"
      }, {
        uniqueName: "Color"
      }],
      columns: [{
        uniqueName: "Business Type",
      }],
      measures: [{
        aggregation: "sum",
        uniqueName: "Price"
      }],
      expands: {
        rows: [{
          tuple: ["category.[accessories]"]
        }]
      }
    },
    options: {
      grid: {
        "showTotals": "off"
      }
    }
  }
});


function hideTotals() {
  pivot.setOptions({
    grid: {
      showTotals: "off"
    }
  });
  pivot.refresh();
}

function showTotals() {
  pivot.setOptions({
    grid: {
      showTotals: "on"
    }
  });
  pivot.refresh();
}