setReport(report: ReportObject)
Sets a report to be displayed in the component. Use this method to load and show previously saved reports.
| Parameter/Type | Description |
|---|---|
| report ReportObject | Describes the report and contains all its properties. |
1) Set report:
<script src="flexmonster/flexmonster.js"></script>
<button onclick="setReport()">Set report</button>
<div id="pivotContainer">The component will appear here</div>
<script>
const pivot = new Flexmonster({
container: "pivotContainer",
});
function setReport() {
let report = {
dataSource: {
filename: "https://cdn.flexmonster.com/data/data.csv"
}
}
pivot.setReport(report);
}
</script>
Open the example on JSFiddle.
2) Swap two reports:
<script src="flexmonster/flexmonster.js"></script>
<button onclick="swapReports()">Swap reports</button>
<div id="firstPivotContainer">The component will appear here</div>
<div id="secondPivotContainer">The component will appear here</div>
<script>
const pivot1 = new Flexmonster({
container: "firstPivotContainer",
toolbar: true,
report: {
dataSource: {
filename: "data1.csv"
}
}
});
const pivot2 = new Flexmonster({
container: "secondPivotContainer",
toolbar: true,
report: {
dataSource: {
filename: "data2.csv"
}
}
});
function swapReports() {
const report1 = pivot1.getReport();
const report2 = pivot2.getReport();
pivot1.setReport(report2);
pivot2.setReport(report1);
}
</script>
Open on JSFiddle.
getReport
shareReport
ReportObject
open
load
save
Save and restore the report