Trees use hierarchical data, take a top-level flat collection, and use
the dataDescriptor to get children collections.  A custom datadescriptor
can apply a filter to the children collections, and even apply different
filters to different children collections.  In Moxie, there should be a
HierarchicalCollection that supports filtering.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of TJ Downes
Sent: Tuesday, October 16, 2007 11:22 AM
To: [email protected]
Subject: [flexcoders] Re: searching or filtering a tree

 

Chris, did you find a solution for this problem?

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "zenwarden" <[EMAIL PROTECTED]> wrote:
>
> Ignore the comment below. It is acceptable (at least in a hack) to
> always return true. 
> 
> Sadly, this code example is not working, but it has put me on the
> right trail. 
> 
> Thanks.
> 
> Chris 
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "zenwarden" <cwarden@> wrote:
> >
> > How does this work? You are always returning true.
> > 
> > 
> > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "dwischusen" <dwischusen@>
wrote:
> > >
> > > Hi Chris,
> > > 
> > > Yes, if you want a filterFunction to work on hierarchical data
then
> > > you will need to override refresh(). The following class is a
bit of
> > > a hack, but it does work:
> > > 
> > > 
> > > public class FilterCollection extends XMLListCollection
> > > {
> > > public function FilterCollection(source:XMLList):void
> > > {
> > > super(source);
> > > }
> > > 
> > > override public function refresh():Boolean
> > > {
> > > this.localIndex = this.toArray();
> > > 
> > > var copy:XMLListCollection = new
> > > XMLListCollection(XMLList(this.toXMLString()));
> > > 
> > > doFilter(this.filterFunction, copy.children());
> > > function doFilter(filterFunc:Function, items:XMLList):void
> > > {
> > > var len:int = items.length();
> > > for (var i:int = len-1; i >= 0; i--)
> > > {
> > > var childList:XMLList = items[i].children();
> > > if (!filterFunc(items[i]))
> > > {
> > > delete items[i];
> > > }
> > > if (childList.length() > 0)
> > > {
> > > doFilter(filterFunc, childList);
> > > }
> > > 
> > > } 
> > > }
> > > 
> > > this.localIndex = copy.toArray();
> > > return true;
> > > }
> > > }
> > > 
> > > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "zenwarden" <cwarden@> wrote:
> > > >
> > > > I have a type in the msg. below it should be Tree control not
IEEE.
> > > > 
> > > > 
> > > > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "zenwarden" <cwarden@> wrote:
> > > > >
> > > > > Hi,
> > > > > 
> > > > > I have a IEEE control that I wish to make searchable. I found
> a good
> > > > > example of Filtering Data In Flex at the forta blog.
> > > > > See:
> > > >
> http://www.forta.com/blog/index.cfm/2006/7/13/Filtering-Data-In-Flex.
<http://www.forta.com/blog/index.cfm/2006/7/13/Filtering-Data-In-Flex.> 
> > > > > 
> > > > > When I tried to apply this to a tree I found that the filter
> > function
> > > > > only iterates over the top level nodes of an
XMLListCollection.
> > > > > 
> > > > > Does this mean I have to overwrite refresh() in
XMLListCollection?
> > > > > That's not a trivial task.
> > > > > 
> > > > > Does anyone have any suggestions or experience with this?
> > > > > 
> > > > > Chris
> > > > >
> > > >
> > >
> >
>

 

Reply via email to