I import XML data in order to fill an AdvancedDataGrid (using Flex 4.5).
This ADG is correctly filled with the data, columns display the right information etc. etc.
I would like to summarize this ADG using
<mx:SummaryRow summaryPlacement="group">
<mx:SummaryField2 dataField="Cost" label="amount" summaryOperation="SUM">
</mx:SummaryRow>
But there is a problem! Indeed, the 'Cost' data are imported as 'Strings' and that is why I cannot do the SUM... I just get a nice 0 as a result! I would like to convert these data into Numbers, so that the addition can be processed. This conversion has to be done before filling the ADG I think.
I already tried to implement a custom summaryOperation but was unlucky...
public function calculateSummary(data:Object, field:SummaryField2, rowData:Object):void
{
var dataField:String = field.dataField;
var value:Number = Number(rowData[dataField]);
Alert.show(rowData[dataField]);
if (!data.hasOwnProperty(dataField))
data[dataField] = value ;
else
data[dataField] += value;
}
The Alert always displays a void message, the data are not transmitted to this function I think
There is another thing: the user can insert new data in the XML dynamically and that insertion has to update the SUM result.
Could anybody help me? I will go on searching and if I find something, I would post it :D
Thank you!