filteropen & filterclose

Events

by juvian

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<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 id="pivot-container">The component will appear here</div>

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

CSS

.output {
  width: 80%;
  height: 300px;
  margin-left: auto;
  margin-right: auto;
  padding: 20px;
  background: rgba(242, 242, 242, 1);
  font-family: Menlo, Monaco, "Courier New", Courier, monospace;
  white-space: pre-wrap;
  font-size: 16px;
  font-weight: 400;
  overflow-y: scroll;
  margin-top: 20px;
  margin-bottom: 10px;
}

code {
    font-size: 105%;
    color: #DF3800;
    background-color: #f5f5f5;
    padding: 1px 4px;
    font-family: monospace !important;
    border-radius: 4px;
}

p {
  font-size: 15px;
  line-height: 1.5;
  padding-right: 10px;
  padding-left: 10px;
}

a {
  color: #00a45a;
  text-decoration: none;
}

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;
}

flexmonster.on('filteropen', function (params) {
  showOutput('The filter is opened!');
});

flexmonster.on('filterclose', function (e) {
console.log(thi);
  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
  }];
}