getChildren is creating a separate collection for each branch and caching it.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of hpeter96 Sent: Friday, June 13, 2008 11:31 AM To: flexcoders@yahoogroups.com 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 flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]> wrote: > > Try applying the filter to each child collection. > > > > ________________________________ > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of hpeter96 > Sent: Friday, June 13, 2008 6:13 AM > To: flexcoders@yahoogroups.com <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 ? >