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="pivot-container">The component will appear here</div>

JavaScript

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

/* To see the alert you should change the report. 
   For example, apply any sorting or filtering.   */
flexmonster.on('reportchange', function () {
  flexmonster.on('aftergriddraw', function () {
      flexmonster.off('aftergriddraw');
      save();
  })
});

function save() {
  flexmonster.save({
      filename: 'myreport.json', 
      destination: 'file',
      callbackHandler: 'reportSaved'
  });
}

function reportSaved() {
	alert("Report was changed and saved!") 
}

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
  }];
}