Peter,

e4x is the new XML access notation that complies with ECMA. It will make
your life easy in your scenario by eliminating that ugly getChildren
func and simplifying your code.

In your case, here's how it would work:

public function hideShowFilterFunc(item:Object):Boolean{
   // item.name() is the name of the xml node, i.e. <person>
   if(item.name() == 'person'){
     return true;
   }else if(item.name() == 'Department'){
     // [EMAIL PROTECTED] is the attribute of the <Department> node
     // i.e. <Department isDeptSales="1" >
     // you may have to do an 'indexOf' if your Department nodes are
incremented
     return [EMAIL PROTECTED] == "1";
   }
   return false;
}





--- In flexcoders@yahoogroups.com, "hpeter96" <[EMAIL PROTECTED]> wrote:
>
> Hi Jeff, I'm not sure what you meant by using e4x to get to the
> sub-nodes - does that come in to play when I call the filterFunction ?
>
> Also I'm still not sure if I'm following you right Alex, what I did
was
> change the dataDescriptor's getChildren() function to this :
>
>
>
------------------------------------------------------------------------\
\
> -
>      override public function getChildren(node:Object, model:Object =
> null):ICollectionView
>      {
>          var childrenCollection:ICollectionView;
>          var myCursor:IViewCursor;// =
childrenCollection.createCursor();
>
>          childrenCollection = super.getChildren(node, model);
>
>          if(childrenCollection != null)
>          {
>              childrenCollection.filterFunction =
ff_childrenCollection;
>              childrenCollection.refresh();
>
>          }
>
>          return childrenCollection;
>      }    // END OF getChildren()
>
>      //
>
------------------------------------------------------------------------\
\
> -
>
> And my filterfunction looks like this :
>
>      //
>
------------------------------------------------------------------------\
\
> -
>      //    ff_childrenCollection()
>      //    filterfunction for the children of getChildren
>      private function ff_childrenCollection(item:Object):Boolean
>      {
>          if(item.attribute("visibility") == '1')
>          {
>              return true;
>          }
>
>          return false;
>      }    // END OF ff_childrenCollection()
>
>      //
>
------------------------------------------------------------------------\
\
> -
>
> Now when I'm updating my list, the CPU jumps to 100%, so it sounds
like
> I'm in an endless loop. Plus the top level branches move around - for
> example, I updated a child under a branch at the top of the list and
the
> branch moved down, 2 branches from the bottom. So before it would look
> like this :
>
> BEFORE
>      Company
>        |
>        |-- Department 1
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 2
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 3
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 4
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 5
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Person
>        |-- Person
>        |-- etc..
>
> AFTER :
>      Company
>        |
>        |-- Department 2
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 3
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 1      << it moved here from the top
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 4
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Department 5
>              |-- Person
>              |-- Person
>              |-- etc..
>        |
>        |-- Person
>        |-- Person
>        |-- etc..
>

Reply via email to