0 Replies Latest reply on Feb 8, 2007 10:02 AM by FRBAmy

    Can you filter on numeric field?

      I am trying to filter a field containing numbers, but I can't get it to work. I am doing something similar to the code below, but the name field in my code is a numeric identification field. Can anyone help??

      This is the code from Ben Forta:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="vertical" creationComplete="initApp()">


      // On startup
      public function initApp():void

      // Set filter function // Be careful to set filterFunction // only after ArrayCollection has been // populated.

      // Filter function
      public function processFilter(item:Object):Boolean
      var result:Boolean=false;

      // If no filter text, or a match, then true
      if (!item.name.length
      || item.name.toUpperCase().indexOf(txtFilter.text.toUpperCase()) >= 0)

      return result;

      <!-- Data (use ArrayCollection) -->
      <mx:ArrayCollection id="myData">
      <mx:Object name="Ben Forta" location="Oak Park, MI" phone="(248)555-5555" />
      <mx:Object name="Jane Doe" location="New York, NY" phone="(212)555-1234" />
      <mx:Object name="Jim Jones" location="Atlanta, GA" phone="(414)555-1212" />
      <mx:Object name="Roberta Roberts" location="Chicago, IL" phone="(312)555-4321" />
      <mx:Object name="Steve Stevens" location="Boston, MA" phone="(617)555-5656" />

      <!-- UI -->
      <mx:HBox width="100%">
      <mx:Label text="Filter:"/>
      <mx:TextInput id="txtFilter" width="100%"
      <mx:DataGrid dataProvider="{myData}"
      width="100%" height="100%">
      <mx:DataGridColumn headerText="Name"
      <mx:DataGridColumn headerText="Location"
      <mx:DataGridColumn headerText="Phone"