首页 > 解决方案 > 如何从 Pentaho 的图表中显示带有动态参数的报告?

问题描述

我的仪表板上有一个饼图,使用click action,我设法显示具有一个固定参数的报告。这是我在点击操作上的 JS 函数:

 function showreport(scene) {
        var newWindow;
        if(scene.getCategory()=='POS'){
            newWindow=window.open("url_report?type_lm=POS", 'REPORT');
        }else{
            newWindow=window.open("url_report?type_lm=NEG", 'REPORT');
        }
    } 

这个工作正常。但是现在我也想传递一个动态参数(使用 获得的变量query component,它存储在result var(code_lm)中:这是我所做的:

function showreport(scene) {
    var newWindow;
    var code_lm=this.dashboard.getParameterValue('code_lm');
    if(scene.getCategory()=='POS'){
        newWindow=window.open("url_report?type_lm=POS&code="+code_lm, 'REPORT');
    }else{
        newWindow=window.open("url_report?type_lm=NEG&code="+code_lm, 'REPORT');
    }
} 

这个不行,点击图表什么也没有显示。我发现这条线 var code_lm=this.dashboard.getParameterValue('code_lm');导致了问题。

但是,我做同样的事情button component

function showreport() {
    var code_lm=this.dashboard.getParameterValue('code_lm');
    var newWindow =  window.open("url_report?code=" + code_lm,'REPORT');
} 

它工作得很好,所以我想知道为什么this.dashboard.getParameterValue()在某些情况下不起作用。

谁能告诉我问题出在哪里?

标签: pentahopentaho-cde

解决方案


是的,如果你想从查询组件传递参数值,那么你需要通过在查询组件的post fetch中编写下面的代码来设置参数值。

 function fun(code_lm) { 
dashboard.setParam('yourParamName',code_lm.resultset);
} 

看看这可能会对你有所帮助。如何将从查询组件获得的变量传递给 Pentaho CDE 上的查询?可以帮助你。


推荐阅读