翻譯|使用教程|編輯:王香|2018-08-14 10:08:49.000|閱讀 849 次
概述:本文主要講解如何在Stimulsoft Report.Javascript中應用設計器事件與查看器事件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載Stimulsoft Reports.JS最新版本】
此示例顯示如何使用報表設計器事件,某些設計器操作包含訂閱的事件,例如,保存報表,創建新報表,預覽報表,退出設計器:
// Set the full screen mode for the designer var options = new Stimulsoft.Designer.StiDesignerOptions(); options.appearance.fullScreenMode = true; // Create the report designer with specified options var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false); // Assign the onSaveReport event function designer.onSaveReport = function (e) { var jsonStr = e.report.saveToJsonString(); alert("Save to JSON string complete.") } // Assign the onCreateReport event function designer.onCreateReport = function (e) { var ds = new Stimulsoft.System.Data.DataSet("Demo"); ds.readJsonFile("../reports/Demo.json"); e.report.regData("Demo", "Demo", ds); } // Assign the onPreviewReport event function designer.onPreviewReport = function (e) { switch (e.format) { case Stimulsoft.Report.StiExportFormat.Html: e.settings.zoom = 2; // Set HTML zoom factor to 200% break; } } // Assign the onExit event function designer.onExit = function (e) { } // Create a new report instance var report = new Stimulsoft.Report.StiReport(); // Load report from url report.loadFile("../reports/SimpleList.mrt"); // Edit report template in the designer designer.report = report; // Show the report designer in the 'content' element designer.renderHtml("content");
示例代碼的結果如下圖所示。
此示例顯示如何使用報表查看器事件,某些查看器操作包含您可以訂閱的事件,例如,打印操作,導出結束,設計報表:
// Enable the design button var options = new Stimulsoft.Viewer.StiViewerOptions(); options.toolbar.showDesignButton = true; // Create the report viewer var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false); // Assign the onGetReportData event function viewer.onGetReportData = function (event) { var ds = new Stimulsoft.System.Data.DataSet("Demo"); ds.readJsonFile("../reports/Demo.json"); event.report.regData("Demo", "Demo", ds); } // Assign the onPrintReport event function viewer.onPrintReport = function (event) { } // Assign the onReportExport event function viewer.onEndExportReport = function (event) { switch (event.format) { case Stimulsoft.Report.StiExportFormat.Html: event.settings.zoom = 2; // Set HTML zoom factor to 200% break; } } // Assign the onReportDesign event function viewer.onDesignReport = function (event) { alert("Design button presed."); } // Create a new report instance var report = new Stimulsoft.Report.StiReport(); // Load report from url report.loadFile("../reports/SimpleList.mrt"); // Assign report to the viewer, the report will be built automatically after rendering the viewer viewer.report = report; // Show the report viewer in the 'content' element viewer.renderHtml("content");
示例代碼的結果如下圖所示。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn