Skip navigation
Currently Being Moderated

How to apply filterFunction to children?

Jul 30, 2012 11:50 PM

Tags: #flex #recursive #filterfunction #xmllistcollection


I was working on filtering the XMLListCollection data based on certain criteria. It all works fine on the top level. But nothing seems to work on the subsequent child levels!



myXMLListCollection =

<row id="1" name="abcg" status="unchecked"/>

<row id="2" name="abcd" status="checked">

     <row id="22" name="abcd" status="checked"/>

     <row id="23" name="abcd" status="unchecked">

     <row id="24" name="abcd" status="checked">

          <row id="241" name="abcdef" status="unchecked"/>

          <row id="242" name="ghijk" status="unchecked"/>

          <row id="243" name="lmnop" status="unchecked"/>


<row id="3" name="abce" status="checked"/>

<row id="4" name="abcf" status="unchecked"/>


myXMLListCollection.filterFunction = myFunc;



private function myFunc(item:Object):Boolean


     if(item.@status == 'checked')


           return true;



           return false;



This gives me back only the rows with ids 2 and 3. And under the row having id as 2, it wont filter it's children nodes!


Can you let me know how we can filter those child nodes as well? I came across few blogs which talked about recursive filtering, but not sure how to make it work...


Appreciate your help..





More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points