JSFiddle - React, Tailwind, and code Playground

by lekhrajpanjwani

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button onclick="pdf()">Export to PDF</button>
<div id="pivot-container"></div>

JavaScript

var pivot = new Flexmonster({
	container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 430,
  toolbar: true,
  report: {
    dataSource: {
      data: getData()
    },
    options: {
			viewType: "grid",
      grid: {
        type: "flat"
      }
    }
  }
});

function pdf() {
 var widgetName = "myWidget";
  const posParams = {
    filename: widgetName,
    pageFormat:"A2",
    pageOrientation: "landscape",
    header: "<div style='text-align: center; width:100%; padding: 10px;'><h5>" +widgetName+"</h5></div>"
  };
  flexmonster.exportTo('pdf', posParams);
}

function getData() {
  return [{
    "Color": "green",
    "M": "September",
    "W": "Wed",
    "Country": "Canada",
    "State": "Ontario",
    "City": "Toronto",
    "Price": 174,
    "Quantity": 22,
    "AA": 0.00,
    "BB": 0.00,
    "CC": 0.00,
    "DD": 0.00,
    "EE": 0.00,
    "FF": 0.00,
    "GG": 0.00,
    "HH": 0.00,
    "II": 0.00,
    "JJ": 0.00,
    "KK": 0.00,
    "LL": 0.00,
    "MM": 0.00,
    "NN": 0.00,
  }, {
    "Color": "red",
    "M": "March",
    "W": "Mon",
    "Time": "1000",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 1664,
    "Quantity": 19
  }, {
    "Color": "red",
    "M": "January",
    "W": "Mon",
    "Country": "Canada",
    "State": "Quebec",
    "City": "Montreal",
    "Price": 1190,
    "Quantity": 292
  }, {
    "Color": "green",
    "D": "04/08/2014",
    "M": "August",
    "W": "Fri",
    "Time": "1000",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 1222,
    "Quantity": 730
  }, {
    "Color": "white",
    "M": "March",
    "W": "Wed",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 7941,
    "Quantity": 73
  }, {
    "Color": "red",
    "M": "August",
    "W": "Wed",
    "Country": "Canada",
    "State": "Ontario",
    "City": "Toronto",
    "Price": 6829,
    "Quantity": 19
  }, {
   ...