IcCube - 使用 Javascript 访问报告代码

IcCube - accessing Report Code with Javascript

当我编辑报告时,我可以点击"Report Code" 来查看有关报告结构的信息。它看起来像这样:

{
"classID": "ic3.ReportGuts",
"guts_": {
    "ic3Version": 12,
    "schemaName": "test_schema",
    "cubeName": "Cube",
    "layout": {
        "classID": "ic3.FixedLayout",
        "guts_": {
            "ic3Version": 12,
            "grid": 10,
            "boxes": [
                {
                    "classID": "ic3.FixedLayoutBox",
                    "guts_": {
                        "ic3Version":...

如何使用 Javascript 访问此信息? context.$report 显然没有提供此信息。

还有没有办法得到信息,报表的不同图表中使用了哪些MDX语句?这可以用 Javascript 改变吗?

要获取报告内容,请将此代码添加到 报告代码:

function consumeEvent( context, event ) {                                
  if (event.name == 'ic3-report-init') {                                 
    console.log(event.value.state.report);
  }                                                                      
}

至于在发送前处理 mdx 请求,有点难。再次在 ReportCode:

function consumeEvent( context, event ) {                                
   if (event.name == 'ic3-report-init') {       
    event.value.widgetMgr().forEach(function(idx,item){
        if(item.hasOwnProperty('onVizBeforeRequestSend')){
            return;
        }

        var oldMethod = item.onVizBeforeRequestSend.bind(item);
        item.onVizBeforeRequestSend = function(request){
            console.log(item, request);
            oldMethod(request);
        }
    });
}

在此函数中,项目是 widgetAdapter,其中包含有关小部件的信息,请求是请求实例。