Styling subtotals and grand totals

Customize cells

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 .fm-total-classic-r {
  background-color: #B2DBBF;
}
#fm-pivot-view #fm-grid-view .fm-grand-total-r {
  background-color: #70C1B3;
}
#fm-pivot-view #fm-grid-view .fm-grand-total-c {
  background-color: #247BA0;
}

JavaScript

var pivot = new Flexmonster({
	container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 500,
  toolbar: true,
  report: {
    "dataSource": {
      "data": getData()
    },
    "slice": {
      "rows": [{
        "uniqueName": "Country"
      }, {
        "uniqueName": "Business Type"
      }, {
        "uniqueName": "Category"
      }, {
        "uniqueName": "[Measures]"
      }],
      "columns": [{
        "uniqueName": "Color"
      }],
      "measures": [{
        "uniqueName": "Price"
      }],
      "expands": {
        "rows": [
          {
            "tuple": [
              "country.[australia]"
            ]
          },
          {
            "tuple": [
              "country.[australia]",
              "business type.[warehouse]"
            ]
          }
        ]
      }
    },
    "options": {
      "grid": {
        "type": "classic"
      }
    }
  }
});

var context = "Context";

flexmonster.customizeCell((cell, data) => {
  console.log(context);
  if (data.isClassicTotalRow) cell.addClass("fm-total-classic-r");
  if (data.isGrandTotalRow) cell.addClass("fm-grand-total-r");
  if (data.isGrandTotalColumn) cell.addClass("fm-grand-total-c");
});

function getData() {
  return [{
    "Category": "Accessories",
    "Size": "262 oz",
    "Color": "red",
    "Destination": "Australia",
    "Business Type": "Specialty Bike Shop",
    "Country": "Australia",
    "Price": 174,
    "Quantity": 225,
    "Discount": 23
  }, {
    "Category": "Accessories",
    "Size": "214 oz",
    "Color": "yellow",
    "Destination": "Canada",
    "Business Type": "Specialty Bike Shop",
    "Country": "Canada",
    "Price": 502,
    "Quantity": 90,
    "Discount": 17
  }, {
    "Category": "Components",
    "Size": "235 oz",
    "Color": "green",
    "Destination": "Australia",
    "Business Type": "Warehouse",
    "Country": "Australia",
    "Price": 551,
    "Quantity": 1950,
    "Discount": 51
  }, {
    "Category":...