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>

<div id="wrapper">
  <div id="pivotContainer"></div>
</div>

CSS

#wrapper {
  width: 500px;
  height: 700px;
  overflow: scroll;
}

#fm-pivot-view .fm-grid-column,
#fm-pivot-view .fm-grid-column-mobile {
  min-width: 120px;
  max-width: 120px;
}

JavaScript

var pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  width: "100%",
  height: "100%",
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    options: {
      grid: {
        type: "classic"
      }
    }
  }
});

let container = document.getElementById("pivotContainer");
let defaultWidth = container.getBoundingClientRect().width;
let fallbackWidth = 5000;
let minWidth = 500;
let widthMargin = 50;

flexmonster.on("reportcomplete", () => {
  flexmonster.off("reportcomplete");
  flexmonster.on("update", () => {
    container.style.width = `${fallbackWidth}px`;
    flexmonster.refresh();
    flexmonster.on("aftergriddraw", () => {
      flexmonster.off("aftergriddraw");
      let resWidth = 0;
      setTimeout(() => {
        let frozenAreaWidth = document.querySelector('.fm-ui-element.fm-sheet-headers').getBoundingClientRect().width;
        let scrollAreaWidth = document.querySelectorAll('.fm-ui-element.fm-scroll-placeholder')[0].getBoundingClientRect().width;
        resWidth = frozenAreaWidth + scrollAreaWidth;
        if (resWidth < minWidth) {
          resWidth = defaultWidth;
        }
        container.style.width = `${resWidth + widthMargin}px`;
        flexmonster.refresh();
      }, 300)
    })
  });

  //to restrict manual switch to compact
  flexmonster.on("reportchange", () => {
    if (flexmonster.getOptions().grid.type == "compact") {
      flexmonster.setOptions({
        grid: {
          type: "classic"
        }
      });
      flexmonster.refresh();
    }
  })
});