Lomadee, uma nova espécie na web. A maior plataforma de afiliados da América Latina



Luiz Henrique de Angeli

luizdeangeli@gmail.com


Arrastar e Soltar (Drag and Drop)

terça-feira, 14 de julho de 2009

Abaixo um exemplo em flex de Arrastar e Soltar entre Grids.

ArrastarSoltar.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*"
 creationComplete="init()">
 <mx:TitleWindow width="100%" height="100%">
  <mx:HBox x="0" y="0" width="100%" height="100%">
   
   <mx:DataGrid id="dtgEsquerdo" dataProvider="{dadosEsquerdo}" width="50%" height="100%"
     dragEnabled="true" dropEnabled="true" dragMoveEnabled="true">
    <mx:columns>
     <mx:DataGridColumn headerText="Código" dataField="codigo"/>
     <mx:DataGridColumn headerText="Nome" dataField="nome"/>    
    </mx:columns>
   </mx:DataGrid>
   
   <mx:DataGrid id="dtgDireito" dataProvider="{dadosDireito}" width="50%" height="100%"
    dragEnabled="true" dropEnabled="true" dragMoveEnabled="true">
    <mx:columns>
     <mx:DataGridColumn headerText="Código" dataField="codigo"/>
     <mx:DataGridColumn headerText="Nome" dataField="nome"/>    
    </mx:columns>
   </mx:DataGrid>
   
  </mx:HBox>
 </mx:TitleWindow>
 <mx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
   
   [Bindable] private var dadosEsquerdo : ArrayCollection = new ArrayCollection();
   [Bindable] private var dadosDireito : ArrayCollection = new ArrayCollection();  
   
   private function init():void
   {
    dadosEsquerdo.addItem({codigo : '1', nome : 'Luiz Henrique'});
    dadosEsquerdo.addItem({codigo : '2', nome : 'Maria'});
    dadosEsquerdo.addItem({codigo : '3', nome : 'Marcela'});
    dadosEsquerdo.addItem({codigo : '4', nome : 'José'});
   }
   
   
  ]]>
 </mx:Script>
 
</mx:Application>

0 comentários:


Submarino.com.br
Submarino.com.br