0 Replies Latest reply on Feb 8, 2010 9:25 AM by edwinmerced

    Export contents to XML file from datagrid

    edwinmerced Level 1

      How can I write to an XML file (or export to it) from dtaa that has been read into a datagrid?


      I need to export the content in a datagrid every time the user clicks the close button on the following application:



      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">


              import mx.collections.ArrayCollection;
              import mx.events.DataGridEvent;
              import mx.utils.ArrayUtil;
              private var jan:Number;
              private var feb:Number;
              private var mar:Number;
              private var apr:Number;
              private var may:Number;
              private var jun:Number;
              private var jul:Number;
              private var aug:Number;
              private var sep:Number;
              private var oct:Number;
              private var nov:Number;
              private var dec:Number;
              private var dataset:ArrayCollection = new ArrayCollection( [
                  { Month: "January", Data: jan },
                  { Month: "Febuary", Data: feb },
                  { Month: "March", Data: mar },
                  { Month: "April", Data: apr },
                  { Month: "May", Data: may },
                  { Month: "June", Data: jun },
                  { Month: "July", Data: jul },
                  { Month: "August", Data: aug },
                  { Month: "September", Data: sep },
                  { Month: "October", Data: oct },
                  { Month: "November", Data: nov },
                  { Month: "December", Data: dec } ]);
           <mx:SeriesSlide id="seriesSlide" duration="3000" direction="up" />
            <mx:Model id="results" source="../data/data.xml"/>
        <mx:ArrayCollection id="myAC" source="{ArrayUtil.toArray(results.item)}"/>


          <mx:ViewStack id="viewstack1" width="464.46967" height="408.18182" horizontalCenter="-12" verticalCenter="0">
              <mx:Canvas id="Data" width="100%" height="100%">
                  <mx:TitleWindow id="DataA" width="450" height="350" layout="absolute" title="Data" horizontalCenter="0" verticalCenter="-10" showCloseButton="true" close="viewstack1.selectedChild=Graph;" >
                      <mx:DataGrid x="11" y="10" width="405.98486" height="290" dataProvider="{myAC}" editable="true">
                              <mx:DataGridColumn width="200" headerText="Month" dataField="month" editable="false" sortable="false" />
                              <mx:DataGridColumn headerText="Data" dataField="data" editable="true" sortable="false" />
              <mx:Canvas id="Graph" width="100%" height="100%">
                  <mx:TitleWindow  id="GraphA" width="450" height="350" layout="absolute" title="Graph" horizontalCenter="0" verticalCenter="-10" showCloseButton="true" click="viewstack1.selectedChild=Data;">
                      <mx:ColumnChart x="8" y="8" id="columnchart1" width="412.12122" height="290" dataProvider="{myAC}">
                      <mx:CategoryAxis categoryField="month"/>
                              <mx:ColumnSeries displayName="Series 1" xField="month" yField="data" showDataEffect="{seriesSlide}"/>