1 Reply Latest reply on Mar 16, 2007 9:22 AM by tobrown779

    populating a data grid

    Gboro54 Level 1
      I am just starting to learn flex2 and action script(I have been a java and c++ programmer mainly unitl now). I am trying to simply populate a datagrid using data from a simple xml file:
      <root>
      <data name="First Record" value="Blah" id="123456"/>
      <data name="Second" value="Blah" id="123456"/>
      <data name="3rd Record" value="Blah" id="123456"/>
      <data name="Stuff" value="Blah" id="123456"/>
      <data name="Engrish" value="Blah" id="123456"/>
      <data name="This and That" value="Blah" id="123456"/>
      <data name="Last Record" value="Blah" id="123456"></data>
      </root>

      Here is the code that my employer has helped me come up with so far:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init();" layout="absolute">
      <mx:DataGrid x="10" y="10" width="578" height="223" dataProvider="{dataXML.data}">
      <mx:columns>
      <mx:DataGridColumn headerText="Name" dataField="@name"/>
      <mx:DataGridColumn headerText="Value" dataField="@value"/>
      <mx:DataGridColumn headerText="ID" dataField="@id"/>
      </mx:columns>
      </mx:DataGrid>

      <mx:HTTPService id= "feedData" result="" resultFormat="e4x" url="data.xml">

      </mx:HTTPService>

      <mx:Script>
      <![CDATA[

      [Bindable]
      private var dataXML:XML = new XML("");

      private function init():void
      {
      //call httpService. On Result assign it to the DataXML object
      feedData.send();
      }
      private function get lastResult():Object
      {
      return XML(feedData.lastResult);
      }
      ]]>
      </mx:Script>

      </mx:Application>

      I am a little lost on what to do or what to do to finish this up. If someone could help clairfy this and help me solve this it would be appricated