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="clearCustomizing()">Clear Customizing</button>
<button onclick="startCustomizing()">Start Customizing</button>

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

CSS

.notexpandable {
  cursor: initial;
}

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  reportcomplete: () => {
    flexmonster.expandData("Color");
    setDrills(flexmonster.getMembers("Data"));
    flexmonster.off("reportcomplete");
  },
  customizeCell: customizeCellFunction,
  report: {
    "options": {
      "grid": {
        "showHierarchies": false
      }
    },
    "dataSource": {
      "mapping": {
        "Country": {
          "hierarchy": "Data"
        },
        "Destination": {
          "hierarchy": "Data",
          "parent": "Country"
        },
        "Business Type": {
          "hierarchy": "Data",
          "parent": "Destination"
        }
      },
      "filename": "data/data.json"
    },
    "slice": {
      "rows": [{
        "uniqueName": "Data",
        "filter": {
          "members": [
            "data.[australia]"
          ]
        }
      }],
      "columns": [{
        "uniqueName": "Color"
      }, {
        "uniqueName": "Size"
      }, {
        "uniqueName": "[Measures]"
      }],
      "measures": [{
        "uniqueName": "Price"
      }],
    }
  }
});


function setDrills(members) {
  members.forEach(member => {
    flexmonster.drillDownCell("rows", [], null, member.uniqueName);
    member.children.forEach(child => {
      flexmonster.drillDownCell("rows", [], null, child.uniqueName);
    })
  })
}

function customizeCellFunction(cell, data) {
  if (data.hierarchy && ((
      data.hierarchy.uniqueName == "Data" && data.level === 0) || data.hierarchy.uniqueName === "Color")) {
    let parts = cell.text.split(data.escapedLabel);
    if (parts.length == 2) {
      cell.text = `<div class='notexpandable' onclick='preventExpand(event)'>${data.escapedLabel}</div>${parts[1]}`;
    }
  }

}

function preventExpand(e) {
  e.stopImmediatePropagation();
}

function clearCustomizing() {
  pivot.customizeCell();
}

function startCustomizing() {
  pivot.customizeCell(customizeCellFunction);
}