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>

<h3>
  Try exporting using the "Export" tab on the Toolbar
</h3>

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

CSS

.highlight {
  background-color: yellow !important;
}

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    "dataSource": {
      "filename": "data/data.json"
    },
    "slice": {
      "rows": [{
        "uniqueName": "Country"
      }, {
        "uniqueName": "Business Type"
      }],
      "columns": [{
        "uniqueName": "Color"
      }, {
        "uniqueName": "[Measures]"
      }],
      "measures": [{
        "uniqueName": "Price"
      }, {
        "uniqueName": "Quantity"
      }],
      "expands": {
        "rows": [{
            "tuple": [
              "country.[australia]"
            ]
          },
          {
            "tuple": [
              "country.[canada]"
            ]
          }
        ]
      }
    }
  }
});

pivot.on("exportcomplete", pivot.customizeCell);
pivot.on("printcomplete", pivot.customizeCell);

function hideSubotals(cell, data) {
  if (data.isTotal && !data.isGrandTotal)
    cell.text = "";
}

pivot.on("beforetoolbarcreated", (toolbar) => {
  let tabs = toolbar.getTabs();
  toolbar.getTabs = () => {
    let exports = tabs.find(tab => tab.id == "fm-tab-export").menu;
    if (!exports) return;

    exports.forEach(tab => {
      let hanlder =
        tab.args ? () => {
          pivot.exportTo(tab.args);
        } : () => {
          pivot.print();
        };
      tab.handler = () => {
        pivot.on("aftergriddraw", () => {
          pivot.off("aftergriddraw");
          hanlder();
        });
        pivot.customizeCell(hideSubotals);
      }
    });

    return tabs;
  };
});