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()
    },
    options: {
      editing: true
    }
  }
});

flexmonster.on('datachanged', function(e) {
  let modDataObj = {};
  modDataObj.id = e.data[0].id;
  modDataObj.field = e.data[0].field;
  modDataObj.newValue = e.data[0].value;
  modDataObj.oldValue = e.data[0].oldValue;
  console.log("id:", modDataObj.id);
  console.log("field:", modDataObj.field);
  console.log("old value:", modDataObj.oldValue);
  console.log("new value:", modDataObj.newValue);

  $.ajax({
    type: "POST",
    url: '/echo/json/',
    data: JSON.stringify(modDataObj),
    dataType: "json",
    success: function(data) {
      console.log("Data was successfully sent.");
    },
    error: function(data) {
      console.log("Error sending the data.");
    }
  });
});


function getData() {
  return [{
      "Color": {
        type: "string"
      },
      "RowId": {
        type: "id"
      },
      "Price": {
        type: "number"
      }
    },
    {
      "Color": "green",
      "RowId": 1,
      "Price": 174
    }, {
      "Color": "red",
      "RowId": 2,
      "Price": 30
    }
  ];
}