3 Replies Latest reply on Jan 24, 2008 6:36 PM by Cachelas

    Auto Refreshing DataGrid when XML file source changes.

    Cachelas
      I'm new at Flex2 and tried looking everywhere for this, including this forums, but I still don't have it clear.

      I want to Auto Refresh a DataGrid that contains the data of a XML, every time the XML file changes.
      I read something about data Binding but still the dataGrid isn't refreshing the data.
      The program needs to show live data all the time.

      I use HTTPService to connect to the XML file.

      I'm sure this isn't the first time asked, so if you could link me to a site, or another post it would be great.
      Thanks for any help,

      ######################

      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="100%"
      height="450"
      creationComplete="memosSv.send()">

      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;
      [Bindable]
      private var memos:ArrayCollection;
      private function memosHandler (event:ResultEvent):void {
      memos = event.result.memos.memo;
      }

      ]]>
      </mx:Script>

      <mx:states>
      <mx:State name="memoCuerpo">
      <mx:AddChild position="lastChild">
      <mx:Panel width="342" height="402" layout="absolute" title="Contenido Del Memo">
      <mx:TextArea
      x="10" y="10"
      width="304"
      height="342"
      cornerRadius="10"
      editable="false"
      selectable="false"
      text="{memos.getItemAt(dgMemos.selectedIndex).contenido}" fontSize="12"/>
      </mx:Panel>
      </mx:AddChild>
      </mx:State>
      </mx:states>

      <mx:HTTPService
      id="memosSv"
      url=" http://222.222.221.225/distefanoRIA/memos.xml"
      result="memosHandler(event)"
      showBusyCursor="true" />

      <mx:DataGrid
      dataProvider="{memos}"
      width="301"
      sortableColumns="false"
      id="dgMemos"
      click="currentState='memoCuerpo'">
      <mx:columns>
      <mx:DataGridColumn width="190" id="columnaTitulo" dataField="titulo" headerText="Titulo del Memo"/>
      <mx:DataGridColumn id="columnaFecha" dataField="fecha" headerText="Fecha Creado"/>
      </mx:columns>
      </mx:DataGrid>

      </mx:HBox>
      ##################