【发布时间】:2021-11-07 10:51:34
【问题描述】:
我有一个报表设计器组件并将方法分配给onSaveReport 事件,但在该方法中我的组件成员是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
}
}
这是错误:
无法设置未定义的属性(设置'body') TypeError:无法在 $.onReportSave [as onSaveReport] (http://localhost:4200/features-stimulsoft-report-stimulsoft-report-module.js:1206:28) 处设置未定义的属性(设置“body”)$ .invokeSaveReport (http://localhost:4200/assets/lazyBundles/stimulsoft/stimulsoft.designer.js:30:82619) 在 $.raiseCallbackEventAsync (http://localhost:4200/assets/lazyBundles/stimulsoft/stimulsoft.designer. js:30:86029) 在 http://localhost:4200/assets/lazyBundles/stimulsoft/stimulsoft.designer.js:30:78818 在 ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:12178:35 ) 在 Object.onInvokeTask (http://localhost:4200/vendor.js:72788:33) 在 ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:12177:40) 在 Zone.runTask (http: //localhost:4200/polyfills.js:11946:51) 在invokeTask (http://localhost:4200/polyfills.js:12259:38) 在ZoneTask.invoke (http://localhost:4200/polyfills.js: 12248:52)`
【问题讨论】:
标签: javascript angular typescript stimulsoft