任何人都可以向我提供一个如何在Flex中使用高级数据网格的示例吗?
我试图从数据库中获取值并构造分层数据。特别是,为高级数据网格构建动态分层数据。
答案 0 :(得分:2)
官方文档中有一些示例:http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_07.html
您可能也对HierarchicalData类感兴趣:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/HierarchicalData.html
答案 1 :(得分:0)
你可以试试这个
<mx:AdvancedDataGrid left="0"
right="0"
top="0"
bottom="35"
allowMultipleSelection="false"
folderClosedIcon="{null}"
folderOpenIcon="{null}"
defaultLeafIcon="{null}"
displayItemsExpanded="true"
dataTipFunction="testTip"
sortExpertMode="true" variableRowHeight="true" wordWrap="true">
<mx:dataProvider>
<mx:HierarchicalData source="{dpHierrarchy}"/>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Result Name"
dataField="resultName"
width="150"
/>
<mx:AdvancedDataGridColumn headerText="Run Date"
dataField="runDate"
/>
<mx:AdvancedDataGridColumn headerText="File Count"
dataField="fileCount"
width="300"
/>
</mx:columns>
</mx:AdvancedDataGrid>
从服务结果中获得的结果形成“dpHierrarchy”,如下所示:
[ArrayElementType("ResultsVO")]
public var dpHierrarchy:ArrayCollection = new ArrayCollection();
public function createHierarchialResultVO(results:ArrayCollection):void
{
for each(var result:Result in results)
{
var resultVO:ResultsVO= new ResultsVO();
resultVO.resultName = result.resultName;
resultVO.runDate = result.runDate.toString();
resultVO.type="header";
var childrens:ArrayCollection = new ArrayCollection();
for each(var processDetails:ProcessDetails in result.details)
{
var children:ResultsVO= new ResultsVO();
children.files =result.fileCount;
children.status=result.status;
children.type="result";
}
resultVO.children =children;
dpHierrarchy.addItem(resultVO);
}
//return dpHierrarchy;
}
高级数据网格将如下所示