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.row-class {
font-family: "Times New Roman";
background-color: #AEC670;
font-weight: bold;
color: #344C11;
}
JavaScript
let pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
height: 300,
customizeCell: customizeCellFunction,
report: {
dataSource: {
data: getData(),
mapping: {
"statusId": {
type: "id"
}
}
},
options: {
drillThrough: false,
grid: {
type: "flat",
showTotals: "off",
showGrandTotals: "off"
}
},
}
});
function customizeCellFunction(cell, data) {
if (data.recordId == 'Active') {
//Add class to a row
//where column satisfied the condition
cell.addClass("row-class");
//Add attribute to a row
//where column satisfied the condition
cell.attr["myattribute"] = data.label;
}
};
function getData() {
return [{
accountId: 23,
name: "My test acccount XYZ",
status: "Active",
statusId: "Active",
address: "321 Michigan Sq., #55"
}, {
accountId: 32,
name: "My test acccount ABC",
status: "Inactive",
statusId: "Inactive",
address: "123 Oxford Av., #23",
},
{
accountId: 33,
name: "My test acccount DEF",
status: "Active",
statusId: "Active",
address: "123 Oxford Av., #23",
}
]
}