What I did was to create a function that does the matching.
Call a function on the change event of the text input, it fires for each 
character entered:

  private function getFilteredItems(sFilterString:String):void
  {
    var sFilterString:String = tiFilter.text;
    var xmlTemp:XML = new XML(<generatedsection />);
    var xlFilteredItems:XMLList;      
    xlFilteredItems = 
_xmlData..item.(itemContains(attribute("item"),sFilterString))
    xmlTemp.setChildren(xlFilteredItems);
    _xmlCurrentSection  = xmlTemp; 
  }//

The "itemContains()" function looks like this:
  private function itemContains(sItem:String, sMatch:String):Boolean
  {
    sItem = sItem.toLowerCase();
    sMatch = sMatch.toLowerCase();
    return (sItem.indexOf(sMatch) != -1);
  }//contains

Tracy
________________________________________
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of donvoltz
Sent: Wednesday, December 12, 2007 9:02 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Filtering XMLList (ala search)

Is it possible to have a search field whose text property is bound to
a function that is called when the field is changed. I would like to
use what ever is typed into the search field to filter an XMLList that
is bound to a datagrid. I would like this to filter dynamically with
each letter typed. I have been able to use e4x filtering of a list for
a given tag, however, this is only for a full piece of data such as
lastname == 'smith'. what I would like to do is when an S is typed,
all of the S lastnames are filtered.

Thanks for any help in advance

Sincerely,

Don
 

Reply via email to