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>
<button onclick="exportToCsv()">
Export to CSV
</button>
<div id="pivotContainer"></div>
JavaScript
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData()
},
options: {
grid: {
type: "flat"
}
}
}
});
function restoreState() {
flexmonster.customizeCell();
}
function removeBlanks() {
flexmonster.customizeCell((cell, data) => {
if (data.label == "(blank)") {
cell.text = "";
}
});
}
function exportToCsv() {
removeBlanks();
flexmonster.exportTo("csv");
}
flexmonster.on("exportcomplete", restoreState);
function getData() {
return [{
Item: "Car",
Price: 48643
}, {
Item: null,
Price: 23765
}, {
Item: "Boat",
Price: 348673
}, {
Item: null,
Price: 48967
}]
}