我有一个AdvancedDataGrid,价格为一列。我想在Grid的底部显示价格总和。它没有分组工作正常,但当我使用分组时,它无法正常工作,我无法理解为什么 错误是: “属性'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>
和dataprovider是:
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}];