如何使用fireEvent在icCube

时间:2016-12-27 14:00:04

标签: iccube iccube-reporting

我有一个多选过滤器小部件,其中包含一个demension成员,可以将其用作我的mdx中的过滤器。这在mdx中使用@ {filter)可以正常工作。好像过滤器是每个用户唯一的,我想将它存储在数据库中,并在用户登录时加载它。这样可以正常工作并将过滤器作为JSON对象:


    data = [{
        "servicenumbers": [{
            "name": "+31880440723",
            "uniquename": "[Inkomend nummer].[Inkomend nummer].[Nummer].&[76]&[2308]"
        },
        {
            "name": "+31880440747",
            "uniquename": "[Inkomend nummer].[Inkomend nummer].[Nummer].&[76]&[2329]"
        },
        {
            "name": "+31880440758",
            "uniquename": "[Inkomend nummer].[Inkomend nummer].[Nummer].&[76]&[3670]"
        },
        {
            "name": "+31880440727",
            "uniquename": "[Inkomend nummer].[Inkomend nummer].[Nummer].&[76]&[2312]"
        }]
    }]

在我的javascriptcode中,我有一个“fireEvent”事件来实际设置过滤器。代码:


    function consumeEvent( context, event ) {                                
        var $report = context.$report;
        var fireEvent = context.fireEvent.bind(context);
        ... 
        some code
        ...

        fireEvent('filter',buildEvent(data));
    }


    function buildEvent(sel)
    {
     return {
            fireMdxByDefault: false,
            isGlobalFilter_: true,
            classID: viz.event.SetSelectionEvent,
            constructor: function w(A,B,z){x.call(this,B,z);this.classID="viz.event.SetSelectionEvent";this.selection=A},
            caption: function (){if(this.selection&&this.selection.length>0){return ic3.asMdxSet(this.selection,"name",false,true)}else{return""}},
            asMdx: function (){if(this.selection&&this.selection.length>0){return ic3.asMdxSet(this.selection,"uniqueName")}else{return null}},
            asFilterInitialSelection: function (){if(this.selection&&this.selection.length>0){return ic3.arrayProps(this.selection,"uniqueName")}else{return""}},
            getSelectedItems: function (){return this.selection},
            isSelectionEvent: function (){return true},
            isGlobalFilter: function (){return this.isGlobalFilter_},
            isEmptyEvent: function (){return false},
            value: function (){return this.asMdx()},
            asSet: function (){return this.asMdx().replace(/^\(/,"{").replace(/\)$/,"}")},
            asDefaultValue: function (){return this.asFilterInitialSelection()},
            asReportParam: function (){var H={};H.rpe=1;if(this.isEmptyEvent()){H.nil=true}else{var A=this.caption();if(A!==null){H.dft=A}var D=this.value();if(D!==null){H.val=D}var z=this.asMdx();if(z!==null){H.mdx=z}var x=this.asFilterInitialSelection();if(x!==null){H.fis=x}if(this.isSelectionEvent()){var B=this.getSelectedItems();if(B!==null){H.sel=B}}}return H},
            selection: sel.servicenumbers
        };  
    }

如果我在MDX @ {filter}中使用“过滤器”,则会在查询中应用过滤器。但是如果我在我的过滤器小部件中将它用作“do set Selection”,则它不会应用选择并且不会选择任何内容。

有人建议如何使这项工作?

0 个答案:

没有答案