0 Replies Latest reply on Apr 29, 2010 1:04 PM by cyber0897

    how do you add multiple filters to an arrayCollection?

    cyber0897 Level 1

      hey guys... so i have three checkboxes and when i click one of them i need to filter out my array collection according to which ones are clicked

       

      I have the filter function working partially, but when i select multiple checkboxes i dont see anything in the arraycollection.

       

      the code i have is

       

       

      <s:VGroup x="-100" y="400">
           <mx:HRule />
           <s:CheckBox label="Approved Stories" color="#333333" selected="@{_approved}" change="filterChanged()" />
           <s:CheckBox label="Rejected Stories" color="#0184C7" selected="@{_rejected}" change="filterChanged()" />
           <s:CheckBox label="Pending Stories" color="#50C8E8" selected="@{_pending}" change="filterChanged()" />
      </s:VGroup>
      
      <s:DataGroup width="100%" height="100%" clipAndEnableScrolling="true" dataProvider="{filteredStoryDataArr}" click="itemClicked();">
      </s:DataGroup>
      
      
      private function returnesAllStories(event:ResultEvent):void{
           for each(var item:Object in event.result){
                storyDataArr.addItem(item);
           }
           
           filteredStoryDataArr = new ArrayCollection(storyDataArr.source);
           filteredStoryDataArr.filterFunction = storyFilter;
      }
      
      
      public function storyFilter(item:Object):Boolean
      {
           return    (!_approved || ((item.ApprovedBy > 0) && (item.DateApproved != ""))) && 
                  (!_pending || ((item.ApprovedBy == -1) && (item.DateApproved == ""))) && 
                  (!_rejected || ((item.ApprovedBy == 0) || (isNaN(item.ApprovedBy))));
      } 
      public function filterChanged():void{
           filteredStoryDataArr.refresh();
      }
      

       

       

      right now if i click approved i see all the approved stories, or if i check pending, i see all the pending stories.... but if i check pending and rejected, i dont see anythign in the list... any ideas how to fix that???