advanced datagrid
Can anyone provide me with an example of how to use the advanced datagrid in Flex?
I am trying to get the values from a database and construct the hierarchial data. In particular, construc开发者_C百科ting the dynamic hierarchal data for advanced datagrid.
There are some examples in the official documentation: http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_07.html
You might also be interested in the HierarchicalData class: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/HierarchicalData.html
You can try this
<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>
Form the "dpHierrarchy" from the result obtained from the service result as given below:
[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;
}
The advanced datagrid will look like this
精彩评论