JSFiddle - React, Tailwind, and code Playground

Events

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<p>
  Switch to flat form to trigger the condition within the
  <code>reportchange</code> and show alert.
</p>

<div id="pivot-container">The component will appear here</div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  height: 340,
  report: {
    dataSource: {
      data: getData(),
    },
  },
});

let gridType;

pivot.on("reportcomplete", function () {
  gridType = pivot.getOptions().grid.type;
});

pivot.on("reportchange", function () {
  let oldGridType = gridType;
  gridType = pivot.getOptions().grid.type;
  if (oldGridType != "flat") {
    if (gridType == "flat") {
      alert("Switched to flat");
    }
  }
});

function getData() {
  return [
    {
      Color: "green",
      M: "September",
      W: "Wed",
      country: "Canada",
      state: "Ontario",
      city: "Toronto",
      Price: 174,
      Quantity: 22,
    },
    {
      Color: "red",
      M: "March",
      W: "Mon",
      Time: "1000",
      country: "USA",
      state: "California",
      city: "Los Angeles",
      Price: 30,
      Quantity: 19,
    },
  ];
}