【问题标题】:IcCube - javascript function applied to all reportsIcCube - 应用于所有报告的 javascript 函数
【发布时间】:2016-08-17 15:35:49
【问题描述】:

可以将 javascript 代码放入 ic3report-local.js 以在每个报告中使用。 可以在报表的 Javascript 中调用其中的函数。

但是是否有可能在每个报告中自动触发特定事件(例如在构建之后)的函数?还是我必须在每个报告中都调用它?

我们希望在构建后为每个报告添加一个词汇表。

【问题讨论】:

    标签: javascript iccube-reporting


    【解决方案1】:

    您可以尝试附加到全局报告事件:

    var reporting = ic3.startReport(options);
    reporting.bind(viz.EventType.onReportRendered, 
                   function(){
                       alert("report rendered")
                   }
    );
    

    在 ic3reporting-local.js 中使用此功能是可用的,但可能会破坏加载顺序,因为您需要使用您自己的实现包装其中一个启动方法(因为在加载此文件时我们没有报告实例) .在将以下代码添加到全局 javascript 文件之前,请确保您使用的是最新的可用版本。

    var originalStart = ic3.startReport;
    ic3.startReport = function(options) {
        var reporting = originalStart(options);
        reporting.bind(viz.EventType.onReportRendered, 
                       function(){
                           alert("report rendered")
                       });
        return reporting;
    }
    

    如果应用此代码后出现任何问题,您可以从 icCube IDE 的 Docs -> applocal -> ic3reporting-local.js 编辑 ic3reporting-local.js

    【讨论】:

    • 我将它放入 ic3report-local.js(在 5.1.7 和 5.2.0 中),但什么也没发生。我还尝试将“viz.EventType”换成“vizEventType”和“viz.event”(我在这里找到它们:stackoverflow.com/questions/28608244/…stackoverflow.com/questions/34812708/…)。不幸的是,仍然没有发生任何事情。那些即包是开源的,以便我可以在某处看到存在哪些事件?搜索“viz onReportRendered”并没有给我一个页面。
    • 已更新用于 ic3reporting-local,但如果您可以访问集成 html,那么最好使用答案的第一部分
    • ic3report-local.js 的代码运行良好。至于另一段代码,我不知道该放在哪里。您编写集成 html,但我不知道那是什么。我尝试了 ic3report.html,但没有奏效。可能是我放错地方了……
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多