JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button onclick="setMembDatePattern()">Change date format</button>
<div id="pivot-container"></div>
JavaScript
var jsonData = [{
billDate: {
type: "date string"
},
"type": {
"type": "number"
}
},
{
billDate: "2020-02-05",
"type": 1
},
{
billDate: "2019-10-15",
"type": 2
},
{
billDate: "2015-12-22",
"type": 2
},
{
billDate: "2019-11-09",
"type": 1
}
];
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: jsonData,
dataSourceType: "json"
},
slice: {
reportFilters: [],
rows: [{
uniqueName: "billDate"
}],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "type"
}]
}
}
});
function setMembDatePattern() {
pivot.customizeCell(customizeCellFunction);
}
function customizeCellFunction(cell, data) {
if (data.type == 'header' && !data.isTotal) {
let oldDateArr = data.label.split('/');
let newDateLabel = oldDateArr[1] + '/' + oldDateArr[0] + '/' + oldDateArr[2];
cell.text = newDateLabel;
}
}