DataGrid allows Multiple Selection : DataGrid Selection « Grid « Flex






DataGrid allows Multiple Selection

DataGrid allows Multiple Selection
        

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp();">
    <mx:Script>
    
    import mx.events.DragEvent;
    import mx.controls.Alert;
    import mx.collections.ArrayCollection;
    private function initApp():void {
        srcgrid.dataProvider = new ArrayCollection([
            {Artist:'A', Album:'AA', Price:1.99},
            {Artist:'B', Album:'BB', Price:1.99},
            {Artist:'C', Album:'CC', Price:1.99}
        ]);
        destgrid.dataProvider = new ArrayCollection([]);
    }
    public function dragDropHandler(event:DragEvent):void {
        var dragObj:Array= event.dragSource.dataForFormat("items") as Array;
        for (var i:Number = 0; i < dragObj.length; i++) {
            Alert.show(dragObj[i].Artist);
        }
    }
  
    </mx:Script>
    <mx:HBox>
       <mx:DataGrid id="srcgrid" allowMultipleSelection="true" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true">
           <mx:columns>
              <mx:DataGridColumn dataField="Artist" />
              <mx:DataGridColumn dataField="Album" />
              <mx:DataGridColumn dataField="Price" />
           </mx:columns>
       </mx:DataGrid>
       <mx:DataGrid id="destgrid" allowMultipleSelection="true" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" dragDrop="dragDropHandler(event);">
           <mx:columns>
             <mx:DataGridColumn dataField="Artist" />
             <mx:DataGridColumn dataField="Album" />
             <mx:DataGridColumn dataField="Price" />
           </mx:columns>
       </mx:DataGrid>
    </mx:HBox>
</mx:Application>

   
    
    
    
    
    
    
    
  








Related examples in the same category

1.Remove selected item from DataGridRemove selected item from DataGrid
2.Get selected index from DataGridGet selected index from DataGrid
3.Navigate to URL from DataGrid as selection changedNavigate to URL from DataGrid as selection changed
4.Handling a user interaction by passing the event object to a functionHandling a user interaction by passing the event object to a function