Hi All
Guys This is regarding the problem I had few days back. I made
filtering of the List partially working for my app after taking some
help from this group, but I realize a bug in my program. I am making
rest calls to load data in form of XML in List. I need to apply filter
on this list. Depending upon the text entered in the text box , the
list should filter. Now my problem is that the filter is working if
user types the id of my XML node, however I want my code to go through
all the XML file and checks if the entered text matches the attribute
named friendly name and will filter depending upon the friendly name.
Please help me out, Below is the code and I would appreciate if
someone gives me right direction to make it completely working, Please
let me know also if the code is not documented correctly to make it
more sense
Thanks
Anuj
//XML File
<devices>
<device id="uuid:ac14231535625133346546">
<attributes>
<attribute name="Flex"/>
<attribute name="monitor">monitoring</attribute>
<attribute name="version">2.0</attribute>
<attribute name="location">location</attribute>
<attribute name="friendly-name">Camera1</attribute>
<attribute name="type">AIR</attribute>
</attributes>
<schedules/>
</device>
</devices>
/**********************CODE*********************/
//This is REST CALL
<mx:HTTPService id="devicesXML" method="GET" resultFormat="e4x"
                result="devicesXMLHandler(event)" showBusyCursor="true">        
        
        </mx:HTTPService>       
//THis makes call to server
devicesXML.url="http://"+IP+"/config/devices";;
//Thid function is called when values are retreived
private function devicesXMLHandler(event:ResultEvent):void
                        {
                                devicesList = event.result.device;
                                                                
                                //Checks every device
                                for each (var devicesInPool:* in devicesList) {
                                        var deviceName:String = [EMAIL 
PROTECTED];
                                        //var label:[EMAIL PROTECTED];          
                                                                                
                                        devicesInList.push(deviceName);
                                        filteredDevices=new 
ArrayCollection(devicesInList);     

nvrsInPoolList.dataProvider = filteredDevices;
                                filteredDevices.filterFunction=processFilter;
}

//This function calls for assigning label for the entries in the List
box named nvsInPoolList         

private function assignFriendlyName(item:Object):String
                        {               
                                //Checks every device
                                for each (var devicesID:* in devicesList) {
                                        var deviceName:String = [EMAIL 
PROTECTED];
                                        //Checks if the current deviceID 
matches the current item, if so
it will search its attributes
                                        if(deviceName == item.toString()) {
                                                var devicesText:XMLList =
devicesID.child("attributes").child("attribute");
                                                //Checks every attribute tag 
for each device
                                                for each (var 
attributesFriendlyName:* in devicesText) {
                                                        //Checks if the 
attribute name is friendly-name
                                                        if([EMAIL PROTECTED] == 
'friendly-name') {
                                                                var 
friendlynameText:String = attributesFriendlyName.toString();
                                                                return 
friendlynameText;
                                                        }       
                                                }
                                                
                                        }
                                }                                               
                                return item.toString();
                        }                                               
//Filtering Data in the Device List
                        private function processFilter(item:Object):Boolean
            {
                return
String(item).toUpperCase().indexOf(filterText.toUpperCase()) >= 0;
            }
            //Tracking the typed Camera Name 
                        private function doChange():void
                        {
                                if(txtSearch.text!=null)
                                {
                                        this.filterText=txtSearch.text;
                                        this.filteredDevices.refresh();
                                }                               
                        }               

<mx:List id="nvrsInPoolList" allowMultipleSelection="true"
dragMoveEnabled="true" dragEnabled="true" dropEnabled="true" 
                y="105" x="17" height="462" width="294"/>

Reply via email to