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="pivotContainer"></div>

CSS

.fm-cell {
  white-space: pre-wrap !important;
}

#fm-pivot-view .fm-grid-row {
  max-height: 500px;
}

JavaScript

let pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      data: getData()
    },
    options: {
      grid: {
        type: "flat"
      }
    }
  }
});

flexmonster.on("reportcomplete", () => {
  flexmonster.off("reportcomplete");
  subscriptionManager();
  flexmonster.refresh();
});
flexmonster.on("reportchange", subscriptionManager);

function subscriptionManager() {
  flexmonster.off("reportchange");
  flexmonster.on("reportchange", () => {
    flexmonster.off("reportchange");
    flexmonster.on("reportchange", subscriptionManager);
  });
  flexmonster.on("aftergriddraw", () => {
    flexmonster.off("aftergriddraw");
		adjustTableSizes();
  });
}

function adjustTableSizes() {
  let cells = document.querySelectorAll(".fm-cell");
  let highCells = [...cells].filter(cell => cell.clientHeight < cell.scrollHeight);
  let tableSizes = {
    rows: [],
    columns: []
  };
  highCells.forEach(cell => {
    tableSizes.rows.push({
      idx: +cell.getAttribute("data-r"),
      height: cell.scrollHeight
    });
    tableSizes.columns.push({
      idx: +cell.getAttribute("data-c"),
      width: cell.clientWidth
    });
  });
  flexmonster.setTableSizes(tableSizes);
}

function getData() {
  return [{
      Item: "Car",
      Price: 8742,
      Description: "Firm: Volkswagen\nYear: 2019\nState: good"
    },
    {
      Item: "Bike",
      Price: 3846,
      Description: "Firm: Yamaha\nYear: 2010\nState: acceptable"
    }
  ];
}