0 Replies Latest reply: Jul 30, 2012 11:50 PM by megharajdeepak RSS

    How to apply filterFunction to children?

    megharajdeepak Community Member

      Hello...

      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!

       

      Ex:

      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>

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

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

       

      myXMLListCollection.filterFunction = myFunc;

      myXMLListCollection.refresh();

       

      private function myFunc(item:Object):Boolean

      {

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

           {

                 return true;

            }else

            {

                 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..

       

      Cheers!

      Deepak