4 Replies Latest reply on Sep 3, 2009 3:42 PM by TheFlexGuy

    Using Predicate filters in a Custom component

    JohnLikesFlex

      Hello,

      I have a cusom datagrid component, which gets it's data from a XMLListCollection object. The xmlList is a simple <employess><employe1><fname/><lname/></emloye1></employees>

       

      I have a text input as a part of this custom component. I am creating a change event on the control to trigger a filter function filterGrid(). I want the frid to dynamically change data as the user types the characters. Currently i have hardcoded my predicate filter to filter the grid whenever the first char matches J. How can i change this to read the chars from the text input.

       

                  private function filterGrid(event:Event):void {
                    
                      if(text1.text!="") {
                          myXMLCollection.filterFunction = filterEmp;
                      }else {
                          myXMLCollection.filterFunction = null;
                      }
                      myXMLCollection.refresh();
                  }

       

                  private function filterEmp(item:XML):Boolean {
                      var searchResult:XMLList;
                     
                      searchResult = item.(/^J/.test( fname ) );//Help need here
                      trace(searchResult);
                      if(searchResult.length()>0) {
                          return true;
                      }   
                      return false;
                  }

       

      Thanks,