advanced datagrid

1.2k views Asked by At

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, constructing the dynamic hierarchal data for advanced datagrid.

2

There are 2 answers

0
kbgn On

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

enter image description here

0
Christophe Herreman On