a labelfunction will do the calculations as you tab through the fields
or as change rows on the grid.
I use this to do some calculations and it works great.
private function calcAdjAmount(item:Object,column:DataGridColumn):String {
var adjustedAmt:Number;
var emptyField:String = "";
if (item['Num_Cases_Claimed'] != null) {
adjustedAmt = item['Num_Cases_Claimed'] *
Number(removeFormatting.format(item['Net_Promo_Amt']));
return
basicCurrencyFormat.format(adjustedAmt.toString());
}
else {
return emptyField;
}
}
Ben
--- In [email protected], "nall_daniel" <[EMAIL PROTECTED]>
wrote:
>
> No one has an answer to this? Or suggestions?
>
> --- In [email protected], "nall_daniel" <daniel.nall.ctr@>
> wrote:
> >
> > I am using the CF/Flex Application Wizard to generate a basic form
> > based application. I have a Master datagrid that list all the
> > purchase requests a user has submitted and a Detail form for editing a
> > request or submitting a new request. The detail form has a datagrid
> > as a subform. I pass the mx:model the wizard created of the subform's
> > data to this function:
> >
> > [Bindable]
> > public var purchaseTotal:Number;
> >
> > private function grandTotal(myArray:Array):void
> > {
> > purchaseTotal = 0;
> > var length:int = myArray.length;
> > for (var i:int = 0; i < length; i++)
> > {
> > purchaseTotal += Number(myArray[i].Quantity *
myArray[i].UnitCost)
> > }
> > }
> >
> > I assign purchaseTotal variable to the text property of a label and
> > run the function on the subform's datagrid.itemFocusOut event. Now
> > when a user is editing a purchase request, the grand total updates
> > when the user changes either the Quantity or the UnitCost. Couple of
> > problems with what I'm doing:
> >
> > 1. No grand total in the label until the user tabs or clicks through
> > the datagrid subform. How can I get my function to run after the
> > mx:model is created and populated with data?
> >
> > 2. New requests never show a grand total. Where's the model's data?
> >
> > My apologies for being so long winded but I wanted to make sure what I
> > was doing is clear.
> >
> > Cheers,
> >
> > Dan
> >
>