Re: AdvancedDatagrid with a summary row
Okay, I figured it out.
Now, I have two label functions set at the AdvancedDataGridColumn level for
the summary row fields and one labelFunction set at the AdvancedDataGrid level
for all the other fields.
<mx:AdvancedDataGridColumn
id="amountTotal" dataField="sumAmount" labelFunction="sumAmountLabelFunction"
/>
<mx:AdvancedDataGridColumn
id="collectedTotal" dataField="sumCollected" labelFunction="sumCollectedLabelFun
ction" />
In order to avoid a null pointer exception on the sumAmount and sumCollected
fields in the label function, I use the hasOwnProperty() method to check before
access. Otherwise, this exception will happen while expanding the tree.
private function sumAmountLabelFunction(item:Object,
column:AdvancedDataGridColumn):String
{
if(item.hasOwnProperty("sumAmount"))
return this.numberFormatter.format(item.sumAmount);
return "";
}
private function sumCollectedLabelFunction(item:Object,
column:AdvancedDataGridColumn):String
{
if(item.hasOwnProperty("sumCollected"))
return this.numberFormatter.format(item.sumCollected);
return "";
}
|