4 Replies Latest reply on Mar 21, 2010 10:45 PM by 2811821

    i got problem in data provider

    2811821 Level 1

      help how to get data provider value

      during filter(search function) its not searching a string

      i place 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:ArrayCollection;
             
             
                 
                   private function initializeHandler():void

       

                  {
                         userList = (rep.currentItem.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>