IcCube - accessing Report Code with Javascript

喜夏-厌秋 提交于 2019-12-13 06:14:35

问题


When I am editing a report, I can click on "Report Code" to see information about the report structure. It loks like this:

{
"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":...

How can I access this Information with Javascript? context.$report apparently doesn't give this information.

Also is there a way to get the information, what MDX statements are used in the different charts of a report? And can this be altered with Javascript?


回答1:


To get report guts add this code to the Report Code:

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

As for handling mdx request before send, it's kinda harder. Again in 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);
        }
    });
}

In this function item is widgetAdapter with info about the widget and request is request instance.



来源:https://stackoverflow.com/questions/38526926/iccube-accessing-report-code-with-javascript

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