Grid Flex


    
    xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"
    creationComplete="initApp();">
    
        
    

     
         
        import mx.events.DragEvent; 
        import mx.managers.DragManager; 
        import mx.core.DragSource; 
        import mx.collections.IList; 
        import mx.collections.ArrayCollection; 
        private function initApp():void { 
            srcList.dataProvider = new ArrayCollection([ 
            {label:"First", data:"1"}, 
            {label:"Second", data:"2"}, 
            {label:"Third", data:"3"}, 
            {label:"Fourth", data:"4"}, 
            ]); 
            destDG.dataProvider = new ArrayCollection([]); 
        } 
        private function dragDropHandler(event:DragEvent):void { 
            if (event.dragSource.hasFormat("itemsByIndex")) 
            { 
                // Explicitly handle the dragDrop event. 
                event.preventDefault(); 
                // Since you are explicitly handling the dragDrop event, 
                // call hideDropFeedback(event) to have the drop target 
                // hide the drop indicator. 
                // The drop indicator is created 
                // automatically for the list controls by the built-in 
                // event handler for the dragOver event. 
                event.currentTarget.hideDropFeedback(event); 
                // Get drop target. 
                var dropTarget:DataGrid =DataGrid(event.currentTarget); 
                var itemsVector:Vector. =event.dragSource.dataForFormat('itemsByIndex') as Vector.
                var tempItem:Object ={ label: itemsVector[0].label,data: itemsVector[0].data,date: new Date()}; 
                // Get the drop location in the destination. 
                var dropLoc:int = dropTarget.calculateDropIndex(event); 
                IList(dropTarget.dataProvider).addItemAt(tempItem, dropLoc); 
            } 
        } 
      
    
    
        
                    dragDrop="dragDropHandler(event);">