flexmonster style

by BaskarR

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="clearCustomizing()">Clear Customizing</button>
<button onclick="startCustomizing()">Start Customizing</button>

<div id="pivot-container"></div>

CSS

.error-cell {
  background-color: #FFB74D !important;
}

/********************* Styles for the description *********************/

h2 {
  text-align: center;
}

p {
  font-size: 15px;
  line-height: 1.5;
  padding-right: 10px;
  padding-left: 10px;
}

a {
  color: #00a45a;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
    font-size: 105%;
    color: #DF3800;
    background-color: #f5f5f5;
    padding: 1px 4px;
    font-family: monospace !important;
    border-radius: 4px;
}

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  customizeCell: customizeCellFunction,
  toolbar: true,
  report: {
    dataSource: {
      data: getData()
    },
    options: {
      grid: {
        type: "flat",
        showTotals: "off",
        showGrandTotals: "off",
      }
    }
  }
});

const datavalue = [{
			"recordId": 1,
      "status": "valid",
      "color": "green",
    },
    {
    	"recordId": 2,
      "status": "invalid",
      "color": {
        "type" : "invalid",
        "value": "red"
      },
      "name": "Karthi",
      "name1": "Karthi1",
      "name2": "Karthi2",
      "name3": {
      	"type" : "invalid",
        "value": "Karthi3"
      },
      "name4": "Karthi4",
      "name5": "Karthi5",
      "name6": "Karthi6",
    },{
    	"recordId": 3,
      "status": "invalid",
      "color": {
        "type" : "invalid",
        "value": "red"
      },
      "name": "Saran",
      "name1": "Saran1",
      "name2": "Saran2",
      "name3": "Saran3",
      "name4": "Saran4",
      "name5": {
      	"type" : "invalid",
        "value": "Saran5"
       },
      "name6": "Saran6",
    },{
    	"recordId": 4,
      "status": "valid",
      "color": "green",
    },
  ]

let recordId;
function customizeCellFunction(cell, data) {
  //console.log(data,"fn")
  const columnName = data.hierarchy.uniqueName || '';
  if(cell.type !== "header" && columnName.toLowerCase() === "recordid"){
  	recordId = Number(data.label)-1;
  }
  if(
  cell.type !== "header" && 
  datavalue[recordId] && 
  datavalue[recordId][columnName] && 
  typeof datavalue[recordId][columnName] === "object"
  ) {
  console.log(datavalue[recordId][columnName])
  	cell.addClass('error-cell');
  }
}

function clearCustomizing() {
  pivot.customizeCell(null);
}

function startCustomizing() {
  pivot.customizeCell(customizeCellFunction);
}

function getData() {
  return [{
  		"recordId": 1,
      "status": "valid",
     ...