Click here to Skip to main content
14,735,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have set xml as a dataprovider to the tree control and it's work fine.
but now i want to filter xml for Tree data provider which ever match with the input text. but filter is not working, So Please any one help me.
I am very new to the flex. need help ASAP

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="vertical"
                              import mx.rpc.xml.SimpleXMLDecoder;
                              import mx.collections.ArrayCollection;
                              import mx.controls.Alert;
                              import mx.collections.XMLListCollection;
                              import mx.utils.ObjectUtil;
                              public var dataXML : XML =
                              <ImageGallery >
                                        <Folder Id="0" Name="My Gallery">
                                                  <Image Id="1" Name="Flex" />
                                                  <Image Id="2" Name="Flash" />
                                                  <Image Id="4" Name="Flash" />
                                                  <Image Id="5" Name="Flex4" />
                                                  <Image Id="6" Name="Media"  />
                                                  <Image Id="3" Name="Flex" />
                                                  <Image Id="7" Name="Computer" />
                                                  <Image Id="8" Name="Internet"  />
                                                  <Image Id="9" Name="Firefox" />
                                                  <Image Id="10" Name="Flex" />
                                        <Folder Id="-1" Name="Public Gallery" >
                                                  <Image Id="11" Name="Firefox" />
                                                  <Image Id="12"  Name="Internet" />
                                                  <Image Id="13"  Name="Flex4" />
                                                  <Image Id="14"  Name="Internet" />
                                                  <Image Id="15"  Name="Computer" />
                                                  <Image Id="16"  Name="Internet" />
                                                  <Image Id="17"  Name="Computer" />
                                                  <Image Id="18"  Name="Flash" />
                                                  <Folder Id="-2" Name="Sub Public Gallery" >
                                                            <Image Id="19"  Name="Flex4" />
                                                            <Image Id="20"  Name="Computer" />
                                                            <Image Id="21"  Name="Flash" />
                                                            <Image Id="22"  Name="Flash" />
                                                            <Image Id="23"  Name="Flex4" />
                                                            <Image Id="24"  Name="Internet" />
                                                            <Image Id="25"  Name="Computer" />
                                                            <Image Id="26"  Name="Flash" />
                              private var obj : XMLListCollection = new XMLListCollection();
                               private function onCreationComplete(event:FlexEvent):void
                                         obj.source = dataXML.Folder;
                                         obj.filterFunction = filterFunc as Function;
                              private function filterFunc(item:Object):Boolean
                      var bool : Boolean = item.@Name.match(new RegExp("^" + searchNameInput.text, "i"));
                      return bool;
          <mx:VBox height="100%" width="100%">
          <mx:Label text="Search"/>
          <mx:TextInput id="searchNameInput" change="obj.refresh()"/>
          <mx:Tree id="imageTree" name="TreeView" height="100%" width="100%" labelField="@Name" showRoot="false"
                     dataProvider="{dataXML}"  />
Updated 23-May-12 5:12am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900