I am working on a report designer component and have assigned a method to the onSaveReport
event. However, I am encountering an issue where the member of my component is showing as undefined
.
options: any;
designer: any;
public document: ReportDocument;
reportBody = '';
constructor() {
}
ngOnInit() {
this.document = new ReportDocument();
this.options = new Stimulsoft.Designer.StiDesignerOptions();
this.options.appearance.fullScreenMode = false;
this.designer = new Stimulsoft.Designer.StiDesigner(this.options, 'StiDesigner', false);
var report = new Stimulsoft.Report.StiReport();
var json = { "DataSet": [{ Id: "a", Name: "A" }] }
var dataSet = new Stimulsoft.System.Data.DataSet("JSON");
dataSet.readJson(json)
report.regData("JSON", "JSON", dataSet);
report.dictionary.synchronize();
this.designer.report = report;
this.designer.renderHtml('designer');
this.designer.onSaveReport = this.onReportSave;
}
private onReportSave(e: any) {
this.document.body = e.report.saveToJsonString(); // error is here
}
}
Here is the error message being shown:
Cannot set properties of undefined (setting 'body') TypeError: Cannot set properties of undefined (setting 'body') at $.onReportSave [as onSaveReport] (http://localhost:4200/features-stimulsoft-report-stimulsoft-report-module.js:1206:28) at $.invokeSaveReport (http://localhost:4200/assets/lazyBundles/stimulsoft/stimulsoft.designer.js:30:82619) at $.raiseCallbackEventAsync (http://localhost:4200/assets/lazyBundles/stimulsoft/stimulsoft.designer.js:30:86029) at http://localhost:4200/assets/lazyBundles/stimulsoft/stimulsoft.designer.js:30:78818 at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:12178:35) at Object.onInvokeTask (http://localhost:4200/vendor.js:72788:33) at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:12177:40) at Zone.runTask (http://localhost:4200/polyfills.js:11946:51) at invokeTask (http://localhost:4200/polyfills.js:12259:38) at ZoneTask.invoke (http://localhost:4200/polyfills.js:12248:52)