filteropen and filterclose

Events

by Flexmonster Pivot Table

HTML

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

<div>
  <p>
    Open the filter pop-up window to trigger the <code>filteropen</code> event
    that outputs the message under the component.
  </p>
  <p>
    Close the filter pop-up window to trigger the <code>filteclose</code> event
    that outputs the message under the component.
  </p>
</div>

<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/",
  toolbar: true,
  height: 340,
  report: {
    dataSource: {
    	data: getData()
    }
  }
});

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('filteropen', function (params) {
  showOutput('The filter is opened!');
});

pivot.on('filterclose', function () {
  showOutput('The filter is closed!');
});

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": 30,
    "Quantity": 19
  }];
}