title: Flex Datagrid Column Total
body: <p>I have a data grid that that has a title, price, qty and total column. The title, price and qty data is loaded from an xml file and the total is populated with a labelFunction to multiply the price by the qty. </p>
  
  <p>I'm able to populate the total for each row with a labelFunction by returning a string to the row under the total column, but I'm having trouble figuring out how to get the overall total for the total column. I'd like to get the overall total and display it in a textBox/somewhere else outside of the datagrid. </p>
  
  <p>I'm able to get the total by using the updateEsimate function, but it'll only send the total using itemEditEnd on the datagrid (which means i'd have to click on eat qty row for it to tally up) and I'd like it to give me the total automatically once it loads.  </p>
  
  <p>Help Please!</p>
  
  <p>(some sample code)</p>
  
  <pre><code>        public function updateEstimate(event:DataGridEvent):void
          {
              // TODO Auto-generated method stub
  
              var sum:Number = 0;
  
              for(var i:int=0; i&lt;orderGrid.dataProvider.length ; i++) {
  
                  sum += Number(orderGrid.dataProvider.getItemAt(i).total);
                  totaltxt.text = sum.toString();
  
              }
  
              totaltxt.text = sum.toString();
  
          }
  
  
  
  
          public function getTotal(item:Object, column:DataGridColumn):String
          {
  
  
              var sum:Number = item.price * item.quantity;
  
              return sum.toString();
  
  
          }
  </code></pre>
  
  <p></p>
  
  <pre><code>    &lt;mx:XMLListCollection id="xmlProdListColl"
                            source="{productXML.lastResult.offer}"
                            /&gt;
  
  
  &lt;/fx:Declarations&gt;
  &lt;mx:DataGrid id="orderGrid" x="44" y="0" width="640" height="155" 
               dataProvider="{xmlProdListColl}" 
               doubleClickEnabled="true" editable="true"
               itemEditEnd="orderGrid_itemEditEndHandler(event); updateEstimate(event)"&gt;
      &lt;mx:columns&gt;
          &lt;mx:DataGridColumn headerText="Title" dataField="title" editable="false"/&gt;
          &lt;mx:DataGridColumn headerText="Price" dataField="price" editable="false"/&gt;
          &lt;mx:DataGridColumn headerText="Quantity" dataField="quantity"/&gt;
          &lt;mx:DataGridColumn headerText="Total" labelFunction="getTotal" editable="false"/&gt;
      &lt;/mx:columns&gt;
  &lt;/mx:DataGrid&gt;
  
  
  &lt;s:RichText id="totaltxt" width="147" height="84" fontSize="18" text=""  textAlign="center"
              verticalAlign="middle" /&gt;
  </code></pre>