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

    challenging filter function any one can try this

    2811821

      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
          naganagesh

          hi,

           

              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:Application
                  xmlns:mx="http://www.adobe.com/2006/mxml"
                  layout="vertical"
                  xmlns:local="*"
                  initialize="initializeHandler();">
                 
                  <mx:XML id="myXML" format="e4x">
                      <users>
                          <dept id="HR">
                               <user>
                                    <FirstName>mm</FirstName>
                                    <email>mm_it@gmail.com</email>
                               </user>
                               <user>
                                    <FirstName>sss</FirstName>
                                    <email>sss_it@gmail.com</email>
                               </user>
                          </dept>
                          <dept id="Financee">
                               <user>
                                    <FirstName>ffff</FirstName>
                                    <email>fff_it@gmail.com</email>
                               </user>
                               <user>
                                    <FirstName>www</FirstName>
                                    <email>www_it@gmail.com</email>
                               </user>
                          </dept>
                      </users>
                  </mx:XML>
                
                 <mx:Script>
                     <![CDATA[
                         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;
                              userList.refresh();
                             
                          }
                                    
                          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:Script>
                
                
                  <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:FormItem>
                        </mx:Form>
                              <mx:DataGrid dataProvider="{rep.currentItem.user}" width="80%" height="149" x="40" y="62">
                                  <mx:columns>
                                      <mx:DataGridColumn dataField="FirstName"/>
                                      <mx:DataGridColumn dataField="email"/>
                                  </mx:columns>
                              </mx:DataGrid>
                      <mx:Button id="search" label="Search" click="searchUsers()" x="165.5" y="226"/>
              <!--        \\<mx:Button label="Show Data" click="clear()"/>-->           
                          </mx:Canvas>      
                      </mx:Repeater>
                  </mx:TabNavigator>
                
              </mx:Application>