Skip navigation
Currently Being Moderated

Iterate single Column in a Datagrid

May 18, 2012 2:21 AM

How to iterate single column of datagrid using flex3.

i want to iterate only one column.for eg  say column-5.

and sum of all the data in col-5.

 
Replies
  • Currently Being Moderated
    May 21, 2012 5:33 AM   in reply to tiger886

    Here is an example for enumerating the datagrid.  You can easily change it to do selected items instead.  You could also access the dataprovider source directly vs going through datagrid.

     

     

    //Summary function

    protected function UpdateTotal():void

    {

       var fRunningTotal:Number = 0.0;

       var nNodeCount:int = 0;

     

       //Check if the dataprovider is empty.

       if (dgMyDatagrid.dataProviderLength == 0)

       {

          //Nothing to total, return out.

          return;

       }

     

       //Loop through all the nodes

       for (nCount = 0; nCount < dgMyDatagrid.dataProviderLength; nCount++)

       {

           //At the current row in the dataprovider convert the 5th object (0 index = start).

           //Add to the running total.

           //If the dataprovider is an XMLListCollection you could address it by name.

           fRunningTotal += Number(dgMyDatagrid.dataProvider.getItemAt(nCount)[4])

       }

     

       //Do something with the total here... like store it for displaying in a label.

    //

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points