Hi, Thanks in advance for your help with the summaryFunction of the ADG.
I am using an AdvancedDataGrid where we should have cumulative(adding the
prvious values of the summary field to the current summary) values for the
summary field(invoiceTotal). In the summaryFunction(), I am adding the previous
summary field to the current summary field and return the value for each
summary. For some reason, it doesn't give the correct value for the
summary.(it is a huge number which has any relation to the dataprovider). It
all works fine, if I am just adding a constant value to each summaryfield.
when I try to add the previuous summary using a variable, it messes up.
In short, it it is okay to add any constant value(which is not I want), but i
am not able to add previous summary value to the current summary, when I print
the value using trace(), it shows correct value, but when it comes to the ADG,
it is giving a different value.
Please advise, your help is greately appreciated
Below is the summaryField entry inside the AdvancedDataGrid
<mx:SummaryField dataField="invoiceTotal" summaryFunction="sumFun"
label="invoiceTotal" />
Below is the sumFunc()
private var cumulValue:Number = 0;
private function sumFunc(itr:IViewCursor,field:String, str:String=null):Object
{
var sum1:Number=0;
while(!itr.afterLast)
{
var value:Number = Number(itr.current.invoiceTotal);
if(!isNaN(value))
{
sum1+= value;
}
else
{
trace("Not a number"+value);
}
itr.moveNext();
}
var temp:Number = sum1+cumulValue;
cumulValue=cumulValue+sum1;
var temp1:Object= new Number(temp);
return (temp1);
}
Thanks
Simon Mathew