You need to use the dataProvider.  The DataGrid control re-uses the visual elements when you scroll, so all of the total cells don’t really exist all of the time.

 

Folks see this regularly when they use a checkbox renderer in a datagrid and fail to have it set and be set from the dataProvider.  The checked state is not persisted when you scroll.

 

Tracy


From: [email protected] [mailto:[email protected]] On Behalf Of Mike Anderson
Sent: Saturday, October 21, 2006 3:36 PM
To: [email protected]
Subject: RE: [flexcoders] Re: Looping through a DataGrid, in order to get Grand Total from 1 specific Column?

 

Thank You Tim!

 

That would have been my next step, if I couldn't figure out how to get the Column method to work.

 

With that said, isn't there still a way to grab the DataGrid's Column, and then loop through it's values??

 

For example:

 

var myColumn:DataGridColumn = myDataGrid.columns(5);

 

Then perform some looping on this?

 

Or:

 

var myColumn:Object = myDataGrid.columns(5);

 

Just thinking out loud on this - as I am just trying to figure out if this can be done, by grabbing a reference to the DataGridColumn - and then doing my logic.  The problem is, I don't know if it's just the Column reference that gets passed to the Variable, or if the Data comes along with it...

 

Either way, thanks for the idea - and I appreciate the reply,

 

Mike

 


From: [EMAIL PROTECTED]ups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Tim Hoff
Sent: Saturday, October 21, 2006 1:29 AM
To: [EMAIL PROTECTED]ups.com
Subject: [flexcoders] Re: Looping through a DataGrid, in order to get Grand Total from 1 specific Column?

Hi Mike,

You could use calculations like this on the dataProvider and bind the return value to the textField.

private function calculateTotal( myDataProvider : ArrayCollection ) : Number
{    
        var totalAmount : Number = 0;
     
        var n:int = myDataProvider.length;
        for (var i:int = 0; i < n; i++)
        {
             totalAmount += Number(myDataProvider[i].UnitPrice * myDataProvider[i].Quantity);
        }

    return totalAmount;
}

-TH
__________________________________

Tim Hoff
Cynergy Systems, Inc.
http://www.cynergysystems.com 

Office
: 866-CYNERGY 

--- In [EMAIL PROTECTED]ups.com, "Mike Anderson" <[EMAIL PROTECTED]> wrote:
>
> Hello All,
>
> I've done this before with Flash, but for the life of me, I can't
> remember how I did it...
>
> I need to loop though my DataGrid's Rows, and add up each value
> contained in the "Total" Column.
>
> And, I can't use my DataProvider property - because "Total" isn't part
> of the DataProvider - it's a column added to the DataGrid after the fact
> - and then I am using a LabelFunction, in order to populate the Total
> Column (UnitPrice * Quantity).
>
> My goal, is to update a TextInput on the bottom of the page, each time a
> new entry is made on the Grid (or if a value changes). I took care of
> that already - by using the itemEditEnd event...
>
> Sorry for the newbie question - I am having a major mental block right
> now.
>
> Thanks in advance all,
>
> Mike
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to