API call getReport - parameters withGlobals and withDefaults

Configuring the report

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<p>Click the buttons below to output the current report under the component.</p>

<button onclick="getReportGlobals()">Get Report with globals</button>
<button onclick="getReportDefaults()">Get Report with defaults</button>
<button onclick="getReportGlobalsDefaults()">
  Get Report with globals and defaults
</button>

<div id="pivot-container">The component will appear here</div>

<div class="output" id="output">Output will appear here</div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  height: 260,
  global: {
    options: {
      defaultHierarchySortName: "desc",
      readOnly: true
    }
  },
  report: {
    dataSource: {
      filename: "data/data.json"
    },
    options: {
      grid: {
        showGrandTotals: "rows"
      },
    	readOnly: false
    }
  }
});

function getReportGlobals() {
  let report = pivot.getReport({
    withGlobals: true
  });
  showOutput(JSON.stringify(report, null, 2));
}

function getReportDefaults() {
  let report = pivot.getReport({
    withDefaults: true
  });
  showOutput(JSON.stringify(report, null, 2));
}

function getReportGlobalsDefaults() {
  let report = pivot.getReport({
    withGlobals: true,
    withDefaults: true
  });
  showOutput(JSON.stringify(report, null, 2));
}

function showOutput(content) {
  document.getElementById("output").innerText = content;
}