Set grid title or turn off totals with setOptions API call

Options

by Dongor7

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="setTitle()">Set grid title</button>
<button onclick="turnOffTotals()">Turn off totals</button>

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

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    slice: {
      rows: [{
        uniqueName: "Color"
      }, {
        uniqueName: "Country"
      }],
      measures: [{
        uniqueName: "Price"
      }],
      expands: {
        rows: [
          {
            tuple: ["color.[green]"]
          }
        ]
      }
    }
  }
});

function setTitle() {
  flexmonster.setOptions({
    grid: {
      title: "Table One"
    },
    useCaptionsInCalculatedValueEditor: true,
  });
  flexmonster.refresh();
}

function turnOffTotals() {
  var options = flexmonster.getOptions();
  options.grid.showTotals = "off";
  flexmonster.setOptions(options);
  flexmonster.refresh();
}