I have a multiselect filter widget with members of a demension to use it as a filter in my mdx. This works fine by use @{filter) in mdx. As if the filter is per user unique I want to store it in a database and load it if an user logs in. This works fine and getting the filter as a JSON object:
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]" }] }]
In my javascriptcode I have a "fireEvent" event to actually set the filter. code:
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 }; }
If I use "filter" in my MDX @{filter} the filter is applied in the query. But if I use it as a "do set Selection" in my filter widget it doesn't apply the selection and nothing is selected.
Does someone have a suggestion how to make this work?