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"></div>
CSS
#fm-pivot-view .fm-grid-view div.fm-cell.alter {
background-color: #e1e1e1 !important;
}
#fm-pivot-view .fm-grid-view div.fm-header.align-right {
text-align: right !important;
}
/* try this selector instead of one above*/
#fm-pivot-view .fm-grid-view div.fm-header.fm-level-1 {
text-align: right !important;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
height: 400,
customizeCell: customizeCellFunction,
report: {
dataSource: {
filename: "data/retail-data.json"
},
slice: {
rows: [{
uniqueName: "Country"
}],
columns: [{
uniqueName: "Date.Year"
}, {
uniqueName: "Date.Month"
}],
measures: [{
uniqueName: "Price"
}],
expands: {
expandAllColumns: true
}
}
}
});
function customizeCellFunction(cell, data) {
if (data && data.type == "value" && data.rowIndex % 2 == 0) {
cell.addClass("alter");
}
if (data && data.type && data.hierarchy && data.hierarchy.type && data.type == "header" && (data.hierarchy.type == "number" || data.hierarchy.type == "date") /*please continue your condition*/ && data.hierarchy.uniqueName.includes("Month")) {
cell.addClass("align-right");
}
}