彩票走势图

【Stimulsoft Reports.JS教程】设计器事件与查看器事件

翻译|使用教程|编辑:王香|2018-08-14 10:08:49.000|阅读 782 次

概述:本文主要讲解如何在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");

示例代码的结果如下图所示。

stimulsoftJS


 

(二)查看器事件

此示例显示如何使用报表查看器事件,某些查看器操作包含您可以订阅的事件,例如,打印操作,导出结束,设计报表:

// 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");

示例代码的结果如下图所示。

stimulsoftJS


标签:JavaScript 报表报表设计Stimulsoft

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP