Enable or disable controls to expand and collapse inner field values on the grid

Options

by Flexmonster Pivot Table

HTML

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

<p>
  When the
  <a
    href="https://www.flexmonster.com/api/grid-options-object/#disableexpandandcollapse"
    target="_blank"
  >grid.disableExpandAndCollapse</a> option is set to <code>true</code>, controls 
  to expand and collapse inner field values become inactive.
</p>

<div class="switch-container compact">
  <label class="switch">
    <input type="checkbox" onclick="toggleControls()" />
    <span class="slider round"></span>
  </label>
  <span class="text">Toggle <code>disableExpandAndCollapse</code> option</span>
</div>

<div id="pivotContainer"></div>

CSS

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

JavaScript

const pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 700,
  toolbar: true,
  report: {
    dataSource: {
      filename: "data/data.csv",
    },
    slice: {
      columns: [
        {
          uniqueName: "[Measures]",
        },
        {
          uniqueName: "Color",
        },
      ],
      expands: {
        rows: [
          {
            tuple: ["category.[accessories]"],
          },
        ],
      },
      measures: [
        {
          aggregation: "sum",
          uniqueName: "Price",
        },
      ],
      rows: [
        {
          uniqueName: "Category",
        },
        {
          uniqueName: "Country",
        },
      ],
    },
  },
});

function toggleControls() {
  const options = pivot.getOptions();
  const newValue =
  options.grid.disableExpandAndCollapse === true ? false : true;
  options.grid.disableExpandAndCollapse = newValue;
  pivot.setOptions(options);
  pivot.refresh();
}