【问题标题】:How to make a report parameter selection change another report parameter selection values while allowing multiselect for both of them?如何使报表参数选择更改另一个报表参数选择值,同时允许对它们进行多选?
【发布时间】:2021-10-25 10:00:09
【问题描述】:

假设我有一个 table,其中包含 名称 列表,例如“a、b、c”,每个名称都有多个 其他 > 分配的值(一些其他值可以分配给多个/所有名称值,示例如下)。

表格示例: (名称 - 其他):
一个 - 一个
a - ab
一个 - 交流
b - ab
b - bb
b - cb
c - 交流
c - bc
c - 抄送

如何在 birt 中进行制作,以便我可以在一个参数框中选择 names 并获取相应的 other 值以选择另一个参数?我知道可以使用级联参数来做到这一点,但这不允许对第一个参数进行多选,在我们的示例中将是 names 值。 p>

【问题讨论】:

    标签: sql birt


    【解决方案1】:

    在这里找到了部分解决方案:https://forums.opentext.com/forums/developer/discussion/61283/allow-multi-value-for-cascading-parameter 在这里(感谢谷歌翻译^^):https://www.developpez.net/forums/d1402270/logiciels/solutions-d-entreprise/business-intelligence/birt/birt-4-3-1-multi-value-cascade-parameters/

    步骤:
    更改“\birt\webcontent\birt\ajax\ui\dialog\BirtParameterDialog.js”文件内容(在其中一个链接中有一个文件可供下载以进行替换,但如果它死了,我将共享 2 个 sn-ps从它发生变化的地方:

        __refresh_cascade_select : function( element )
    {
        var matrix = new Array( );
        var m = 0;
        for( var i = 0; i < this.__cascadingParameter.length; i++ )
        {
            for( var j = 0; j < this.__cascadingParameter[i].length; j++ )
            {
                var paramName = this.__cascadingParameter[i][j].name;
                if( paramName == this.__isnull )
                    paramName = this.__cascadingParameter[i][j].value;
                    
                if( paramName == element.id.substr( 0, element.id.length - 10 ) )
                {
                    //CHANGE//
                    //The two way work (String(selectedValue) or Array(SelectedValueArray))
                    var l = 0;
                    var isFirstElement = true;
                    var selectedValue = "";
                    var selectedValueArray = new Array();
                    for(var test = 0; test<element.options.length;test++){
                        if(element.options[test].selected){
                            if(isFirstElement){
                                isFirstElement = false;
                                selectedValue = element.options[test].value;
                                
                            }
                            else{
                                selectedValue = selectedValue+","+element.options[test].value;
                            }
                            selectedValueArray[l] = element.options[test].value;
                            l++;
                        }
                    }
                    //CHANGE//
                    
                    var tempText = element.options[element.selectedIndex].text;
                    var tempValue = element.options[element.selectedIndex].value;
                     
                    // Null Value Parameter
                    if ( tempValue == Constants.nullValue )
                    {
                        this.__cascadingParameter[i][j].name = this.__isnull;
                        this.__cascadingParameter[i][j].value = paramName;
                    }                   
                    else if( tempValue == '' )
                    {
                        if( tempText == "" )
                        {
                            var target = element;
                            target = target.parentNode;
                            var oInputs = target.getElementsByTagName( "input" );
                            if( oInputs.length >0 && oInputs[1].value != Constants.TYPE_STRING )
                            {
                                // Only String parameter allows blank value
                                alert( birtUtility.formatMessage( Constants.error.parameterNotAllowBlank, paramName ) );
                                this.__clearSubCascadingParameter( this.__cascadingParameter[i], j );
                                return;
                            }
                            else
                            {
                                // Blank Value
                                this.__cascadingParameter[i][j].name = paramName;
                                this.__cascadingParameter[i][j].value = tempValue;                              
                            }
                        }
                        else
                        {
                            // Blank Value
                            this.__cascadingParameter[i][j].name = paramName;
                            this.__cascadingParameter[i][j].value = tempValue;
                        }                       
                    }
                    else
                    {
                        this.__cascadingParameter[i][j].name = paramName;
                        //CHANGE//
                        //The two way work (String(selectedValue) or Array(SelectedValueArray))
                        this.__cascadingParameter[i][j].value = selectedValueArray;
                        //CHANGE//
                    }
                    
                    for( var m = 0; m <= j; m++ )
                    {
                        if( !matrix[m] )
                        {
                            matrix[m] = {};
                        }
                        matrix[m].name = this.__cascadingParameter[i][m].name;
                        matrix[m].value = this.__cascadingParameter[i][m].value;
                    }
                    this.__pendingCascadingCalls++;
                    birtEventDispatcher.broadcastEvent( birtEvent.__E_CASCADING_PARAMETER, matrix );
                }
            }
        }
    },
    

    还有这个:

    // exist select control and input text/password
            // compare the parent div offsetTop
            if( oFirstITC.parentNode && oFirstST.parentNode )
            {
                // Bugzilla 265615: need to use cumulative offset for special cases
                // where one element is inside a group container
                var offsetITC = Position.cumulativeOffset( oFirstITC );
                var offsetST = Position.cumulativeOffset( oFirstST );
                
                // compare y-offset first, then x-offset to determine the visual order
                if( ( offsetITC[1] > offsetST[1] ) || ( offsetITC[1] == offsetST[1] && offsetITC[0] > offsetST[0] ) )
                {
                    oFirstST.focus( );              
                }
                else
                {
                    oFirstITC.focus( );
                }
            }
    

    .js 更改后,级联参数可以在所有级别上进行多选。 示例:
    第一个数据集“DS_country”查询:

    select CLASSICMODELS.OFFICES.COUNTRY
    from CLASSICMODELS.OFFICES
    

    第二个数据集“DS_office”查询:

    select CLASSICMODELS.OFFICES.OFFICECODE
    from CLASSICMODELS.OFFICES
    where CLASSICMODELS.OFFICES.COUNTRY IN ('DS_country')
    

    创建数据集后,我们可以制作级联报表参数 CRP_country 和 CRP_office(请记住,UI 不允许您在上层选择“允许多个值”,但我们可以在属性编辑器中更改参数后通过转到高级选项卡并将“标量参数类型”属性值更改为“多值”)

    剩下的唯一事情就是选择较低级别的级联参数(在我们的示例中为 CRP_office),然后转到脚本选项卡并将其添加到“beforeOpen”:

    // Do that if your selections are in String type.
    var stringArray = params["CRP_country"].value.toString().split(",");
    var result = "";
    for(var i =0 ; i < stringArray.length ; i++){
        if(i==0){
            result = "'"+stringArray[i]+"'";
        }
        else{
            result = result+",'"+stringArray[i]+"'";
        }
    }
    
    // For String
    this.queryText = this.queryText.replace("'DS_country'", result);
    
    //For integer (the first part is useless)
    //this.queryText = this.queryText.replace("'DS_country'", 
    params["CRP_country"].value);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-12
      • 1970-01-01
      • 2018-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多