fieldslistopen and fieldslistclose

Events

by Flexmonster Pivot Table

HTML

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

<div>
  <p>
    Click the <b>Open the Field List</b> button to trigger the
    <code>fieldslistopen</code> event that outputs a message under the
    component.
  </p>
  <p>
    Click the <b>Close the Field List</b> button to trigger the
    <code>fieldslistclose</code> event that outputs a message under the
    component.
  </p>
</div>

<button onclick="openFieldsList()">Open the Field List</button>
<button onclick="closeFieldsList()">Close the Field List</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

var pivot = new Flexmonster({
	container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 320,
  report: {
    dataSource: {
      data: getData()
    },
    options: {
			configuratorButton: false
    }
  }
});

let outputInitialized = false;

function showOutput(content) {
  var log = "[" + (new Date()).toLocaleTimeString('en-US') + "] " + content;
  var outputElement = document.getElementById("output");
  if (!outputInitialized) {
    outputElement.innerText = '';
    outputInitialized = true;
  }
  outputElement.innerText += log + "\n";
  outputElement.scrollTop = outputElement.scrollHeight;
}

pivot.on('fieldslistopen', function () {
  showOutput('Field list is opened!');
});

pivot.on('fieldslistclose', function () {
  showOutput('Field list is closed!');
});

function openFieldsList() {
  pivot.openFieldsList();
}

function closeFieldsList() {
  pivot.closeFieldsList();
}

function getData() {
  return [{
    "Color": "green",
    "M": "September",
    "W": "Wed",
    "Country": "Canada",
    "State": "Ontario",
    "City": "Toronto",
    "Price": 174,
    "Quantity": 22
  }, {
    "Color": "red",
    "M": "March",
    "W": "Mon",
    "Time": "1000",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 1664,
    "Quantity": 19
  }, {
    "Color": "red",
    "M": "January",
    "W": "Mon",
    "Country": "Canada",
    "State": "Quebec",
    "City": "Montreal",
    "Price": 1190,
    "Quantity": 292
  }, {
    "Color": "green",
    "D": "04/08/2014",
    "M": "August",
    "W": "Fri",
    "Time": "1000",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 1222,
    "Quantity": 730
  }, {
    "Color": "white",
    "M": "March",
    "W": "Wed",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 7941,
   ...