beforegriddraw and aftergriddraw
Events
by Flexmonster Pivot Table
November 28, 2025
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div>
<p>
Before the grid is rendered, the <code>beforegriddraw</code> event is
triggered and outputs the message under the component.
</p>
<p>
After grid is rendered, the <code>aftergriddraw</code> event is triggered
and 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/",
height: 340,
report: {
dataSource: {
data: getData()
},
"slice": {
"rows": [
{"uniqueName": "Color"}
],
"columns": [
{"uniqueName": "Country"},
{"uniqueName": "[Measures]"}
],
"measures": [
{"uniqueName": "Price",
"aggregation": "sum"}
]
}
}
});
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('beforegriddraw', function (params) {
if (params.smooth == false)
showOutput('Before grid draw with row/column scroll!');
else
showOutput('Before grid draw with pixel scroll!');
});
pivot.on('aftergriddraw', function (e) {
if (e.smooth == false)
showOutput('After grid draw with row/column scroll!');
else
showOutput('After grid draw with pixel scroll!');
});
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":...