1 Reply Latest reply on Jun 14, 2007 6:59 AM by BLXWebMaster

    Calculating Totals

    rajeeva_nagaraj
      Hi,

      I have a datagrid in which i am displaying some values at the end i want the row total and column total for row total i am using label function which is working fine but how can i get the column total

      plz find me some solution

      regards
      Rajeev
        • 1. Re: Calculating Totals
          BLXWebMaster Level 1
          I typically loop over the array and do the calculations. I am doing this for over 10 thousand records and have not noticed any performane issues.

          I call a function after my collection has be recieved. I also call the same function after any filters etc.

          Something like this.
          [Bindable]
          public var totalCount:String='';
          [Bindable]
          public var sumPrice:String='';

          private function calcDealAmount():void
          {
          var sum : Number = 0;
          var count : Number = 0;

          var length : int = arCollection.length;
          for( var i : int = 0; i < length; i++ )
          {
          var item : Object = arCollection.getItemAt( i );
          var value : Number = item["Price"];
          if( ! isNaN( value ))
          {
          sum += value;
          count += 1;
          }
          }
          totalCount = count.toString()'
          sumPrice = sumUnfunded.toString();
          }

          You can easily add additional columns to today as needed.