3 Replies Latest reply on Mar 19, 2010 5:46 AM by 2811821

    challenging filter function any one can try this


      i have three tab navigator name is............ HR, sales, finance

      each section have a two data fields name and mail id

      it detail display on datagrid

      i have text input field and button  for each tab navigator

      if i want give name in text input and i click search button it show corresponding search record

      the some function come under sales and finance tab navigator also

        • 1. Re: challenging filter function any one can try this



              i think it is possible. you can get the datagrid data into one place.  Then you datagrid data convert into arraycollection after that you can write filter function for  for builded arracollection and catch the returned search values. i hope it will successfully run

          • 2. Re: challenging filter function any one can try this
            levancho Level 3

            it is quite simple, you will operate on dataprovider somehow you need to convert your dataprovider (if its not already)  to ListCollectionView subtype,

            ArrayCollection and XMLListCollection both extend that class,

            than you can follow this example: http://blog.flexexamples.com/2008/04/15/creating-a-view-cursor-on-an-arraycollection-in-fl ex/

            to search through array Collection. and use filterFunction (if needed) as well to filter arraycollection based on what you find.

            to find items

            • 3. Re: challenging filter function any one can try this
              2811821 Level 1

              hi complete that using repeater concept

              than i implement using filterfunction on some code but its not filtered

              give me some idea based on my code

              this my code








              <?xml version="1.0" encoding="utf-8"?>
                  <mx:XML id="myXML" format="e4x">
                          <dept id="HR">
                          <dept id="Financee">
                         import mx.collections.ICollectionView;
                         import mx.collections.ArrayCollection;
                     [Bindable] private var userList:ICollectionView;
                           private function initializeHandler():void


                                 userList = (myXML.dept); 
                          private function searchUsers():void{
                              userList.filterFunction = filterUsers;
                          private function filterUsers(item:Object):Boolean
                              var isMatch:Boolean = false
                              if(item.FirstName.toLowerCase().search(search1.text.toLowerCase()) != -1)
                                  isMatch = true
                              else if(item.email.toLowerCase().search(search1.text.toLowerCase()) != -1)
                                  isMatch = true
                                  return isMatch;
                  <mx:TabNavigator width="398" height="291">
                      <mx:Repeater id="rep" dataProvider="{myXML.dept}">
                          <mx:Canvas label="{rep.currentItem.@id}">
                          <mx:Form x="53">
                          <mx:FormItem label="Search Names" direction="horizontal">
                              <mx:TextInput id="search1" />
                              <mx:DataGrid dataProvider="{rep.currentItem.user}" width="80%" height="149" x="40" y="62">
                                      <mx:DataGridColumn dataField="FirstName"/>
                                      <mx:DataGridColumn dataField="email"/>
                      <mx:Button id="search" label="Search" click="searchUsers()" x="165.5" y="226"/>
              <!--        \\<mx:Button label="Show Data" click="clear()"/>-->