I have following code that updates data from a csv file created on the server using HTTP in Flex. The problem is that the values are not getting refreshed on the Flex GUI. Below is the example. When I load everything is fine.
When I change the values in data/tempdata.csv file of one row as China,30 I don't see the value of China getting updated. When I check in Alert.show it does receive the value from the server but somehow it's not getting displayed on the GUI. When I click on China or anything else it gets refreshed. Is there anything that I am missing in the code. This is really simple code . All I want to do is update the values from the server csv file. It should not change the hierarchy of the user everytime the data is refreshed. Only the value of the total should change in the below structure. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initHTTPService()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.rpc.events.ResultEvent; import mx.controls.Alert; import flash.utils.Timer; [Bindable] private var dpHierarchy:ArrayCollection= new ArrayCollection([ { region: "USA", total:null }, { region: "India", total:null }, { region: "China", total:null , children : [ { region : 'shangai' , total : 30 } ] }, ]); // this is the default order I want. private function initHTTPService () : void { summaryHttpServiceId.send(); var summaryDataUpdateTimer:Timer = new Timer ( 10000,0 ) ; // update every 3 seconds from the server file summaryDataUpdateTimer.addEventListener( TimerEvent.TIMER, summaryDataUpdateTimerLoad ) ; summaryDataUpdateTimer.start(); } private function summaryDataUpdateTimerLoad ( event:TimerEvent ) : void { summaryHttpServiceId.send(); } private function summaryHandler ( evt:ResultEvent ): void { var dataObj:Object = new Object(); var arr : Array = evt.result.toString().split( "\n" ); for each ( var str : String in arr ) { // the data at this part is in the format India,30 var tmpArr : Array = str.split("," ) ; dataObj[tmpArr[0]] = tmpArr[1]; } for ( var counter:int = 0 ; counter < dpHierarchy.length; counter++ ) { if ( !(dataObj[dpHierarchy[counter]['region']] ) ) continue ; Alert.show ( "Region : " + dpHierarchy[counter]['region'] + " | Total " + dataObj[dpHierarchy[counter]['region']] ) ; dpHierarchy[counter]['total'] = dataObj[dpHierarchy [counter]['region']]; } dpHierarchy.refresh(); } ]]> </mx:Script> <mx:HTTPService id="summaryHttpServiceId" url="../data/tempdata.csv" result="summaryHandler(event)" resultFormat="text" showBusyCursor="true"/> <mx:AdvancedDataGrid id="myADG" width="100%" height="100%" variableRowHeight="true"> <mx:dataProvider> <mx:HierarchicalData source="{dpHierarchy}"/> </mx:dataProvider> <mx:columns> <mx:AdvancedDataGridColumn dataField="region" headerText="region"/> <mx:AdvancedDataGridColumn dataField="total" headerText="Total"/> </mx:columns> </mx:AdvancedDataGrid> </mx:Application> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to flex_india@googlegroups.com To unsubscribe from this group, send email to flex_india+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---