item.zipcode exists because the DataGridColumn -> dataField has a property of "zipcode". If I do item.zipcode, I'm able to search all the zipcode. Take a look here:
https://crux.baker.edu/~thuynh01/flex/ModelLocator.swf type in some number in the text input below the datagrid. What I'm trying to do it have the ability to filter based on what the ComboBox value is. --- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote: > > I would debug or trace out each subexpression. > > > > I don't see how item.zipcode can exist. > > > > -Alex > > > > ________________________________ > > From: [email protected] > [mailto:[EMAIL PROTECTED] On Behalf Of xmrcivicboix > Sent: Wednesday, February 14, 2007 3:49 PM > To: [email protected] > Subject: [flexcomponents] DataGrid filtering help > > > > Hi guys, I have a problem that I don't know if it's possible to do. I > have a DataGrid, a ComboBox, and a Search input field. When I select a > value in the ComboBox I want the text I enter to filter by what I > selected. Here is my code: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml > <http://www.adobe.com/2006/mxml> " width="100%" > height="340"> > > <mx:Script> > <![CDATA[ > import model.UserModelLocator; > import view.UserInfo; > > [Bindable] > private var _userModel:UserModelLocator = > UserModelLocator.getInstance(); > > [Bindable] > private var filtersComboBox:Array = [{field:"Date Registered", > value:"date_registered"}, > {field:"Email Address", value:"email"}, > {field:"First Name", value:"first_name"}, > {field:"Last Name", value:"last_name"}, > {field:"City", value:"city"}, > {field:"State", value:"state"}, > {field:"ZIP Code", value:"zipcode"}, > {field:"Gender", value:"gender"}, > {field:"Disney Optin", value:"disney_optin"}, > {field:"Weather Channel Optin", value:"weather_optin"}]; > > private function filterGrid(): void > { > _userModel.userInfo.filterFunction = filterBy; > _userModel.userInfo.refresh(); > trace(filterList.selectedItem.value); > } > > private function filterBy(item:Object): Boolean > { > var isMatch:Boolean = false; > > /**** THIS IS WHERE I HAVE PROBLEM ****/ > /**** IF I USE > "item.zipcode.toLowerCase().search(search.text.toLowerCase()) != -1" > it works good ****/ > if > (item.(filterList.selectedItem.value).toLowerCase().search(search.text.t > oLowerCase()) > != -1) > { > isMatch = true; > } > > return isMatch; > } > ]]> > </mx:Script> > <mx:Grid width="100%"> > <mx:GridRow width="100%"> > <mx:GridItem width="100%"> > <mx:DataGrid id="userGrid" allowDragSelection="true" > dataProvider="{_userModel.userInfo}" width="100%" height="300"> > <mx:columns> > <mx:DataGridColumn dataField="date_registered" headerText="Date > Registered" minWidth="140"/> > <mx:DataGridColumn dataField="email" headerText="Email Address" > minWidth="200"/> > <mx:DataGridColumn dataField="first_name" headerText="First > Name" minWidth="50"/> > <mx:DataGridColumn dataField="last_name" headerText="Last Name" > minWidth="90"/> > <mx:DataGridColumn dataField="address" headerText="Address" > minWidth="130"/> > <mx:DataGridColumn dataField="address2" headerText="Apt/Suite" > minWidth="50"/> > <mx:DataGridColumn dataField="city" headerText="City" > minWidth="60"/> > <mx:DataGridColumn dataField="state" headerText="State" > minWidth="30"/> > <mx:DataGridColumn dataField="zipcode" headerText="ZIP Code" > minWidth="30"/> > <mx:DataGridColumn dataField="birth_date" headerText="Date of > Birth" minWidth="50"/> > <mx:DataGridColumn dataField="gender" headerText="Gender" > minWidth="30"/> > <mx:DataGridColumn dataField="disney_optin" headerText="Disney > Optin" minWidth="60"/> > <mx:DataGridColumn dataField="weather_optin" headerText="Weather > Channel Optin" minWidth="60"/> > </mx:columns> > </mx:DataGrid> > </mx:GridItem> > </mx:GridRow> > <mx:GridRow width="100%"> > <mx:GridItem width="100%" horizontalAlign="right"> > <mx:ComboBox dataProvider="{filtersComboBox}" labelField="field" > id="filterList" fontSize="11" height="22"/> > <mx:TextInput width="200" height="20" fontSize="9" > change="filterGrid()" id="search"/> > </mx:GridItem> > </mx:GridRow> > </mx:Grid> > </mx:Canvas> >
