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