Can anyone tell me how I can get my event listener to update the total
when the quantity is changed using the numericStepper inside a datagrid?  

Thanks

Sal

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" xmlns="*" creationComplete="calculateTotal()">


[Bindable]
public var total:Number=0;
[Bindable]
public var numProducts:int=0;
[Bindable]
public var myDP:ArrayCollection = new ArrayCollection();
                        
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;
}

public function qtyChangeListener():void{
        qtyChanger.addEventListener("change", calculateTotal);
}

<mx:DataGrid id="grid" dataProvider="{myDP}" textAlign="center">
<mx:columns>
<mx:DataGridColumn headerText="Product" dataField="name"/>
<mx:DataGridColumn id="qtyChanger" headerText="Qty" dataField="qty"
rendererIsEditor="true" itemRenderer="mx.controls.NumericStepper"
editorDataField="value"/>
<mx:DataGridColumn headerText="Price" dataField="price"/>
</mx:columns>
</mx:DataGrid>

<mx:Text text="{total}"/>

</mx:Application>




--
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