<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] private var customersArray:ArrayCollection = new ArrayCollection([ {FirstName:"Barbara", LastName:"Jennings"}, {FirstName:"John", LastName:"Gag"}, {FirstName:"Joe", LastName:"Smith"}, {FirstName:"Brian", LastName:"Sheridan"}, {FirstName:"Chris", LastName:"Sheridan"}, {FirstName:"Jose", LastName:"Reyes"}, {FirstName:"Barbara", LastName:"Walters"}, {FirstName:"Bruce", LastName:"Smith"}, {FirstName:"Barry", LastName:"Sanders"}, {FirstName:"Joe", LastName:"Montana"}, {FirstName:"George", LastName:"Bush"}, {FirstName:"Jim", LastName:"Carey"}, {FirstName:"Roy", LastName:"Holliday"}, {FirstName:"Ryan", LastName:"Braun"}, {FirstName:"Jimmy", LastName:"Kimble"}, {FirstName:"Steve", LastName:"Weyrick"} ]); private function filterContent():void{ if(txtFilter.text.length == 0){ customersArray.filterFunction=null; } else{ customersArray.filterFunction=filterColumn; } customersArray.refresh(); } private function filterColumn(item:Object):Boolean{ var content:String = txtFilter.text.toLowerCase(); var key:String = item.FirstName.toLowerCase(); if(key.indexOf(content)!=-1){ return true } else{ return false } } ]]> </mx:Script> <mx:HBox> <mx:Label text="First Name:"/> <mx:TextInput id="txtFilter" toolTip="Search" change="filterContent();" /> </mx:HBox> <mx:DataGrid id="dg" dataProvider="{customersArray}" width="50%" height="75%" /> </mx:Application>