We are trying to use the pivot table component within Salesforce Lightning Web Components and are receiving some errors.
Here's the Javascript code we are using:
import { LightningElement } from 'lwc';
import { loadScript, loadStyle } from 'lightning/platformResourceLoader';
import xsslds from '@salesforce/resourceUrl/xsslds221'; // Adjust path
export default class Xs_global_analysis extends LightningElement {
isRendered = false;
renderedCallback() {
if (this.isRendered) {
return;
}
this.isRendered = true;
Promise.all([
loadScript(this, xsslds + '/flexmonster.js'),
loadStyle(this, xsslds + '/flexmonster.css')
])
.then(() => {
const pivotContainer = this.template.querySelector('.pivot-container');
if (pivotContainer) {
const pivot = new Flexmonster({
container: pivotContainer,
width: "100%",
height: "100%",
toolbar: true,
report: {
dataSource: {
data: this.getData()
}
}
});
}
})
.catch(error => {
console.error('Error loading Flexmonster:', error);
});
}
getData() {
return [{"Account Name":"Xceede India","FY2025F06":20,"Category":"Actual","Offerings":"Implementation - Inner 1","Offerings Parent":"Implementation","Fiscal Period":"JAN-25","Fiscal Quarter":"Q1","Fiscal Year":"FY2025","Measure":"Revenue - Services","Measure Parent":"Revenue","Plan Source":"Account Planning"}];
}
}
Hello, Sanjiv,
Thank you for reaching out to us.
This issue occurs due to limitations imposed by Lightning Web Security. Flexmonster heavily relies on access to window and document objects, as well as certain events like fullscreenchange, which are restricted by these security settings.
During our research and testing on our side, we discovered that it is possible to disable Lighting Web Security settings for LWC components, which would allow Flexmonster to properly function within the Salesforce environment.
If this approach is not feasible due to your internal constraints, an alternative workaround may be available. Our representative will contact you shortly via email to discuss this option and provide the necessary details.
Best regards,
Maksym