API calls setSort and getSort

Slice configuration

by Flexmonster Pivot Table

HTML

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

<div>
  <p>
    Click <b>Set asc sort</b> or <b>Set desc sort</b> buttons to apply sorting
    to members of the <code>Category</code> field, and the
    <b>Clear sorting</b> button to remove sorting.
  </p>
  <p>
    Click the <b>Get Sort</b> button to output the sort type applied to the
    <code>Category</code> field.
  </p>
</div>

<button onclick="setSort('asc')">Set asc sort</button>
<button onclick="setSort('desc')">Set desc sort</button>
<button onclick="setSort('unsorted')">Clear sorting</button>
<button onclick="getSort()">Get sort</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,
  report: {
    dataSource: {
      filename: "data/data.csv"
    }
  }
});

function setSort(sortType) {
  pivot.setSort("Category", sortType);
}

function getSort() {
  let sort = pivot.getSort("Category");
  showOutput(JSON.stringify(sort, null, 4));
}

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