Free Download Flex 3 Essential Training Video

Hi,
To download Flex 3 Video click on

Flex 3 Essential Training

hope this will useful

any comments then please reply.




Expand and Collapse AdvancedDataGrid Row on click of Row

 

 

Using AdvancedDataGrid we can display hierarchical data. In AdvancedDataGrid by default icon come in every row , if user click on that icon then row expand  and collapse on next click .

By default on row click, AdvancedDataGrid is not getting expand and collapse but it should. Here I am going to write code for expand and collapse AdvancedDataGrid on click of row……………

   

 

<?xml version="1.0" encoding="utf-8" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.HierarchicalData;
import mx.collections.IHierarchicalCollectionView;
private var arr:ArrayCollection=new ArrayCollection([
{fileName:"mxmxmxmx",size:"18587 bytes", lastModified:"November 20, 2006",
children:[{fileName: "mx", size:"5563 bytes", lastModified:"October 6, 2006"},
{fileName:"mx", size:"17045 bytes", lastModified:"November 2, 2006"},
{fileName:"mx", size:"17045 bytes", lastModified:"November 2, 2006"},
{fileName:"mx", size:"17045 bytes", lastModified:"November 2, 2006"},]},
{fileName: "mxmxmx", size:"18587 bytes", lastModified:"November 20, 2006",
children: [{fileName: "mx", size:"169825 bytes", lastModified:"December 6, 2006"}]},
{fileName:"mxmxmxmx", size:"18587 bytes", lastModified:"November 20, 2006",
children:[{fileName: "mx", size:"5563 bytes", lastModified:"October 6, 2006"},
{fileName:"mx", size:"17045 bytes", lastModified:"November 2, 2006"},
{fileName:"mx", size:"17045 bytes", lastModified:"November 2, 2006"},
{fileName:"mx", size:"17045 bytes", lastModified:"November 2, 2006"}]},
{fileName:"mxmxmxmx",size:"18587 bytes", lastModified:"November 20, 2006",
children:[{fileName: "mx", size:"5563 bytes", lastModified:"October 6, 2006"}]}]);

private function expandCollapse(event:Event):void{
var itemClickExpColl:AdvancedDataGrid = event.target as AdvancedDataGrid;
var isItemOpen:Boolean=itemClickExpColl.isItemOpen(itemClickExpColl.selectedItem);
itemClickExpColl.expandItem(itemClickExpColl.selectedItem ,!isItemOpen , true);
}


]]>
</mx:Script>
<mx:Label fontSize="16" text="Expand and Collaps Hierarchical Data on click of AdvancedDataGrid Row"/>
<mx:AdvancedDataGrid id="adg" dataProvider="{new HierarchicalData(arr)}"
displayItemsExpanded="true" width="400" height="350"
itemClick="expandCollapse(event)">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="fileName" />
<mx:AdvancedDataGridColumn dataField="size" />
<mx:AdvancedDataGridColumn dataField="lastModified" />
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Application>