我有一个以价格为一列的 AdvancedDataGrid。我想在网格底部显示总价格。它在没有分组的情况下工作正常但是当我使用分组时它不起作用我不明白为什么错误是:“属性'dataProvider'的多个初始化程序。(注意:'dataProvider'是'mx.controls.AdvancedDataGrid'的默认属性' )。”
我的代码是:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:local="*"
width = "100%" viewSourceURL="srcview/index.html" xmlns:adg="com.forestandthetrees.controls.adgFooter.*">
<mx:AdvancedDataGrid id="myADG1"
variableRowHeight="true">
<mx:dataProvider>
<mx:GroupingCollection id="gc" source="{dp}">
<mx:Grouping label="Sno">
<mx:GroupingField name="category"/>
</mx:Grouping>
</mx:GroupingCollection>
</mx:dataProvider>
<adg:FooterAdvancedDataGrid id="dg4"
paddingTop="0" horizontalScrollPolicy="auto"
paddingBottom="0" verticalAlign="middle" width="100%"
lockedColumnCount="1" >
<adg:columns>
<mx:AdvancedDataGridColumn headerText="Sno" dataField="Sno" />
<mx:AdvancedDataGridColumn headerText="category" dataField="category" />
<mx:AdvancedDataGridColumn headerText="ProductName" dataField="productName" />
<mx:AdvancedDataGridColumn headerText="Description" dataField="description" />
<mx:AdvancedDataGridColumn headerText="AvailableStock" dataField="availableStock" />
<adg:FooterAdvancedDataGridColumn headerText="pricePerItem" dataField="pricePerItem" >
<mx:AdvancedDataGridColumn labelFunction="averageFunctionADG"
dataField="pricePerItem"
/>
</adg:FooterAdvancedDataGridColumn>
</adg:columns>
</adg:FooterAdvancedDataGrid>
</mx:AdvancedDataGrid>
和数据提供者是:
private var dp:Array = [
{Sno:"1",category:"biscuits", productName:"50-50",
description:"salt", availableStock:12,pricePerItem:12},
{Sno:"2",category:"biscuits", productName:"cream",
description:"cream", availableStock:12,pricePerItem:12},
{Sno:"3",category:"choclates", productName:"5star",
description:"choclateflavour", availableStock:12,pricePerItem:12},
{Sno:"4",category:"choclates", productName:"kitkat",
description:"pineappleflavour", availableStock:12,pricePerItem:12},
{Sno:"5",category:"sweets", productName:"sompapad",
description:"asd", availableStock:12,pricePerItem:12},
{Sno:"6",category:"sweets", productName:"laddu",
description:"", availableStock:12,pricePerItem:12},
{Sno:"7",category:"chips", productName:"lays",
description:"salt", availableStock:12,pricePerItem:12},
{Sno:"8",category:"chips", productName:"kurkure",
description:"salt", availableStock:12,pricePerItem:12}];