API call on for setting a JS function for the specified event
Events
by Flexmonster Pivot Table
November 28, 2025
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<p>
Double-click a cell to trigger the <code>celldoubleclick</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
@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()
},
options: {
configuratorActive: 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('celldoubleclick', function () {
showOutput('The cell is double clicked');
});
// If you plan on removing some certain event handler later,
// add it the following way
pivot.on('cellclick', onCellClick);
function onCellClick(result) {
showOutput('The cell is clicked');
}
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,
"Quantity": 73
}, {
...