flex - Checking through an Object and returning if the element is found -


i trying return true items found within object although arrays within object have more 1 element within it. example selectedeventtypes[9] has array of [cancelled,cancelled2,cancelled3], although whenever item.eventtype cancelled2 never realise within object , return false this.

private function eventfilterfucntion(item:object):boolean {        if(selectedeventtypes.indexof(item.eventtype)>-1)     {         return true;     }     return false; } 

it looks have defined selectedeventtypes array of array like:

private var selectedeventtypes:array = [["a1", "a2"],         ["b1","b2"],         ["c1","c2"],         ["d1","d2"],         ["e1","e2"],         ["f1","f2"],         ["g1","g2"],         ["h1","h2"],         ["i1","i2"],         ["cancelled", "cancelled2", "cancelled3"],         ["received","last"]]; 

where

selectedeventtypes[9] = ["cancelled", "cancelled2", "cancelled3"] 

in case can change eventfilterfunction below:

private function eventfilterfucntion(item:object):boolean     {         each(var eacharray:array in selectedeventtypes)         {             if(eacharray.indexof(item.eventtype) > -1)             {                 return true;             }         }         return false;     } 

try sample application:

<?xml version="1.0"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009"            xmlns:s="library://ns.adobe.com/flex/spark"> <fx:script><![cdata[     import mx.collections.arraycollection;     private var selectedeventtypes:array = [["a1", "a2"],         ["b1","b2"],         ["c1","c2"],         ["d1","d2"],         ["e1","e2"],         ["f1","f2"],         ["g1","g2"],         ["h1","h2"],         ["i1","i2"],         ["cancelled", "cancelled2", "cancelled3"],         ["received","last"]];     [bindable]     private var myarraycollectionoriginal:arraycollection = new arraycollection([         {name:"state 1",eventtype:"submitted"},         {name:"state 2",eventtype:"cancelled2"},         {name:"state 3",eventtype:"pending"},         {name:"state 4",eventtype:"cancelled3"},         {name:"state 5",eventtype:"failed"},         {name:"state 6",eventtype:"received"}         ]);     [bindable]     private var otherarraycollection:arraycollection = new arraycollection();     private function applyfilterbuttonclicked():void     {         otherarraycollection = new arraycollection(myarraycollectionoriginal.source)         otherarraycollection.filterfunction = eventfilterfucntion;         otherarraycollection.refresh();     }      private function eventfilterfucntion(item:object):boolean     {         each(var eacharray:array in selectedeventtypes)         {             if(eacharray.indexof(item.eventtype) > -1)             {                 return true;             }         }         return false;     }     ]]></fx:script> <s:hgroup verticalcenter="0" horizontalcenter="0">     <s:panel title="original collection">         <s:datagrid dataprovider="{myarraycollectionoriginal}"/>     </s:panel>     <s:button click="{applyfilterbuttonclicked()}" label="apply filter" />     <s:panel title="filtered output">         <s:datagrid dataprovider="{otherarraycollection}"/>     </s:panel> </s:hgroup>  </s:application> 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -