So I take it that the listener would have to be an conditional "for"
function?  How would I assign the listener to the datagrid? Would I
place it in the "datagrid" property or the "datagrid column" property?  



--- In [email protected], "Dustin Mercer" <[EMAIL PROTECTED]>
wrote:
>
> What you could do... if your myDP is an ArrayCollection or one of the
> collection classes you could add a listener to the change event.  That
> way any time the dataProvider changes (the change event on the
> Collection itself can let you know if an item was added, removed or
> updated) you can recalculate the totals.  That way your total will
> always be in synch with your data without having to manually recalculate
> the total. 
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of s_hernandez01
> Sent: Wednesday, October 25, 2006 3:14 PM
> To: [email protected]
> Subject: [flexcoders] Datagrid Change Function
> 
>  
> 
> Hey Flexers 
> 
> I created a datagrid to represent a shopping cart. Now, I'm having a
> problem updating the total when the quantity is changed. Right now it
> just gives the total because I have the quantity set to 1, but if the
> users types in a different quantity I want it to update the total. If
> anybody has any suggestions, I'd appreciate it. Below is my calculate
> function and my datagrid. 
> 
> Thanks
> Sal
> 
> public function calculateTotal():void{
> var t:Number = 0;
> var n:Number = 0;
> for(var i:int = 0; i < myDP.length; i++){
> n += myDP[i].qty;
> t += myDP[i].price * myDP[i].qty;
> }
> total = t;
> numProducts = n;
> }
> 
> <mx:DataGrid width="100%" height="250" dataProvider="{myDP}"
> textAlign="center" id="cartGrid">
> <mx:columns>
> <mx:DataGridColumn id="qty" headerText="Qty"
> rendererIsEditor="true" dataField="qty"
> itemRenderer="mx.controls.TextInput" editorDataField="value"
> width="24"/>
> <mx:DataGridColumn headerText="Price" width="35"
> dataField="price" labelFunction="myLabelFunction"/>
> 
> </mx:columns>
> </mx:DataGrid>
>





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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to