openingreportfile

Events

by Flexmonster Pivot Table

HTML

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

<div>
  <p>
    Click the <b>Open</b> button to trigger the
    <code>openingreportfile</code> event that outputs the message under the
    component.
  </p>
  <p>
    Click the <b>Cancel</b> button in the Open file dialog to trigger the
    <code>reportfilecancelled</code> event that outputs the message under the
    component.
  </p>
</div>

<button onclick="openReport()">Open</button>

<div id="pivot-container"></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/",
  height: 290,
  report: {
    dataSource: {
      data: getData()
    }
  }
});

pivot.on('openingreportfile', function () {
  showOutput('Opening report file!');
});
pivot.on('reportfilecancelled', function () {
  showOutput('Opening of report file was cancelled!');
});

function openReport() {
  pivot.open();
}

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

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