IcCube - javascript function applied to all reports

末鹿安然 提交于 2020-01-06 02:53:04

问题


It is possible to place javascript code into ic3report-local.js to be used in every report. A function in there can be called in the Javascript of a report.

But is it possible, to have a function in there being fired at a specific event (for example after build) in every report automatically? Or do I have to call it in every report?

We would like to add a glossary to every report after build.


回答1:


You can try attaching to global reporting events:

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

Using this functionality in ic3reporting-local.js is available but could break loading sequence, because you need to wrap one of the start methods with your own implementation(since we don't have an reporting instance while this file is loading). Please, ensure that you're using the latest available version before adding the followng code to global javascript file.

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

If anything goes wrong after applying this code, you can edit ic3reporting-local.js from icCube IDE at Docs -> applocal -> ic3reporting-local.js



来源:https://stackoverflow.com/questions/39000857/iccube-javascript-function-applied-to-all-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!