I might be able to help. I had a similar issue with XMLListCollection
dataProvider for an AdvacncedDataGrid. The filter function works great
and with lists in the 100's. You get the to sub nodes with e4x.

Here's the filtering code:

public function hideShowFilterFunc(item:Object):Boolean{
 if(item.name() == 'category'){
   return true;
 }else if(item.name() == 'item'){
   return [EMAIL PROTECTED] == "1";
 }
 return true;                           
}
                        
// Note setting filterFunction to 'null' does not work so, 
// I had to create a filter func returning true to show all
public function showAllFilterFunc(item:Object):Boolean{
  return true;
}
                
public function filterNotifs():void{                             
 dg.dataProvider.filterFunction = hideShowFilterFunc;
 // invalidateProperties eliminates occassional cursor error
 dg.invalidateProperties();
 // I'm using HeirarchialData so I have to refresh the dg's dp
 // verses the dp directly.
 dg.dataProvider.refresh();                                     
}                       

public function resetNotifs():void{
 dg.dataProvider.filterFunction = showAllFilterFunc;
 dg.dataProvider.refresh();
}
                        
LMK,

Jeff




--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> getChildren is creating a separate collection for each branch and
> caching it.
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of hpeter96
> Sent: Friday, June 13, 2008 11:31 AM
> To: [email protected]
> Subject: [flexcoders] Re: Help with updating a Tree when its
> dataprovider has changed.
> 
>  
> 
> I'm not sure if I understand correctly - Do you mean when I'm parsing
> the dataProvider, I should make a look that creates a separate
> XMLListCollection for each branch and apply the filterFunction before
> I append it to the dataProvider ?
> 
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , "Alex Harui" <aharui@> wrote:
> >
> > Try applying the filter to each child collection.
> > 
> > 
> > 
> > ________________________________
> > 
> > From: [email protected] <mailto:flexcoders%40yahoogroups.com>
> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of hpeter96
> > Sent: Friday, June 13, 2008 6:13 AM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Help with updating a Tree when its dataprovider
> > has changed.
> > 
> > 
> > 
> > I'm working on a tree control that has an XMLListCollection as its
> > dataprovider.
> > 
> > The dataprovider has a couple of branches and nodes that sort of look
> > like this :
> > 
> > Company
> > |
> > |-- Department
> > |-- Person
> > |-- Person
> > |-- etc..
> > |
> > |-- Department
> > |-- Person
> > |-- Person
> > |-- etc..
> > |
> > |-- Person
> > |-- Person
> > |! -- etc..
> > 
> > I'd like to have each Person node appear in the Tree depending on a
> > 'visibility' flag. So if it is set, then the Person node would appear
> > and if its not set, then the Person node won't appear.
> > 
> > What I have right now is each Person node has an attribute called
> > 'visibility' and when it is set to 'ModuleConstants.VISIBILITY_NONE',
> > the tree's dataDescriptor removes them from the list with this
> override
> > :
> > 
> > //
> > ----------------------------------------------------------
> > -
> > override public function getChildren(node:Object, model:Object =
> > null):ICollectionView
> > {
> > var childrenCollection:ICollectionView;
> > var myCursor:IViewCursor;// = childrenCollection.createCursor();
> > 
> > childrenCo! llection = super.getChildren(node, model);
> > 
> > if(childrenCollection != null)
> > {
> > myCursor = childrenCollection.createCursor();
> > 
> > while(!myCursor.afterLast)
> > {
> > // check to see if we want to show this node or not
> > if(Number(myCursor.current.attribute("visibility")) ==
> > ModuleConstants.VISIBILITY_NONE)
> > {
> > myCursor.remove();
> > &nb! sp; }
> > else
> > {
> > myCursor.moveNext();
> > }
> > }
> > }
> > 
> > return childrenCollection;
> > } // END OF getChildren()
> > 
> > //
> > ----------------------------------------------------------
> > -
> > 
> > When I want to show or remove a Person node during runtime, I have a
> > function that :
> > - goes to the specific Department branch and remove all the people
> nodes
> > underneath it.
> > - ! adds all of the Person nodes again, but sets the visibility fl! ag
> > for t he Person nodes I want to appear.
> > - calls the tree's invalidateList() and validateNow() functions
> > respectively.
> > 
> > This works fine for short lists, but once the Tree gets long enough
> that
> > a vertical is needed, the tree control starts messing up the data and
> > doesn't show all of the nodes. Department branches start disappearing
> > and duplicates start appearing and disappearing - all a huge mess.
> > I did a trace on the dataProvider (the XMLListCollection) and that is
> > showing me the correct data - so it seems like the tree is the one
> > having trouble keeping up with all these changes.
> > 
> > Originally I wanted to filter out the Person nodes with the
> > XMLListCollection's filterFunction, but the filterFilter seems to only
> > work on objects at the top level of the hierarchy, which seems to be a
> > huge limitation.
> > 
> > Can anyone help me out ?
> >
>


Reply via email to