6 Replies Latest reply on Dec 13, 2007 11:18 AM by Clarence_69

    Datgrid and total

    Clarence_69
      Hi,
      I'm looking for many times he solution about this question:
      How to get the total from one column of datgrid?
      xml:
      <?xml version="1.0" encoding="utf-8"?>

      <list>
      <quote>
      <date>01/02/2007</date>
      <open>1.25</open>
      <total>0</total>
      </quote>

      <quote>
      <date>04/03/2007</date>
      <open>1.18</open>
      <total>0</total>
      </quote>


      <quote>
      <date>07/07/2007</date>
      <open>1.38</open>
      <total>0</total>
      </quote>

      <quote>
      <date>10/01/2007</date>
      <open>1.28</open>
      <total>0</total>
      </quote>
      <quote>
      <date>11/01/2007</date>
      <open>1.30</open>
      <total>0</total>
      </quote>

      <quote>
      <date>04/02/2007</date>
      <open>1.35</open>
      <total>0</total>
      </quote>

      </list>

      Mxml.

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      creationComplete="dp.send()">
      ****
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      [Bindable]
      public var res:ArrayCollection;


      public function gettotal (item:Object):void{
      var total:Object=0;
      total+=parseFloat(item.open);
      }

      ]]>
      </mx:Script>


      <mx:HTTPService id="dp" url="data/euro.xml"
      result="res = dp.lastResult.list.quote"/>

      <mx:DataGrid id="dg" dataProvider="{res}" width="165" height="240"/>

      <mx:Label name=" TOTAL" text="{gettotal()}" width="215" fontSize="16" color="#EFF70A" fontWeight="bold" x="249" y="10"/>


      </mx:Application>



      Thanks for your support

      --
      Kla