Hi,
I have created Drag and drop functionality from datagrid to list in flex 2 beta 3
Below is the code for it.
But can anybody tell me that how can i get the List data in separate array on click event of the list?
<?xml versionfiltered="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import classes.MyList;
import mx.controls.listClasses.ListBase;
import mx.controls.listClasses.ListItemRenderer;
import mx.events.DropdownEvent;
import flash.display.DisplayObject
import mx.controls.Alert;
import mx.controls.List;
import mx.controls.listClasses.ListData;
import mx.events.ListEventReason;
import mx.events.ListEvent;
import mx.events.DragEvent;
[Bindable]
public var myDragArr:Array=["sumeet","Ashish","Raj","Karuna"]
public var myDropArr:Array= ["group1"];
public var myDropArr1:Array=[]
public var myList:List;
private var count=0;
public static const ITEM_EDIT_END:String = "itemEditEnd"
var event:Event;
public function dragDrop_handler(event:DragEvent)
{
//event.preventDefault()
myDropArr1.push(grid1.selectedItems)
Alert.show(myDropArr1+" event.target")
}
public function dragComplete_Handler(event:DragEvent):void
{
//Alert.show(grid1+"")
}
public function addInstances(event):void
{
count++
myList= new List()
VBOX.addChild(myList);
var myId:String="myList"+count
myList.width=60
myList.height=60
myList.dataProvider="group1";
myList.id=myId
myList.dropEnabled=true
myList.editable=true
myList.addEventListener("itemEditEnd" , itemEditEnd_Handler);
myList.addEventListener("dragDrop",dragDrop_handler)
myList.addEventListener("click",click_handler)
}
public function itemEditEnd_Handler(event:ListEvent):void
{
//Alert.show("Edit End")
myList.editable=false
}
public function click_handler(event:Event)
{
}
]]>
</mx:Script>
<mx:DataGrid allowMultipleSelectionfiltered="true" id="grid1" x="10" y="28" width="231" dragEnabled="true" dataProvider="{myDragArr}" dragComplete="dragComplete_Handler(event)">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
</mx:columns>
</mx:DataGrid>
<!-- <mx:List it id="list1" x="488" y="43" width="122" height="95" dropEnabled="true" dataProvider="{myDropArr}" dragDrop="dragDrop_handler(event)"/> -->
<mx:VBox id="VBOX" x="272" y="28" width="139" height="183">
</mx:VBox>
<mx:Button label="Add" click="addInstances(event)" x="297"/>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import classes.MyList;
import mx.controls.listClasses.ListBase;
import mx.controls.listClasses.ListItemRenderer;
import mx.events.DropdownEvent;
import flash.display.DisplayObject
import mx.controls.Alert;
import mx.controls.List;
import mx.controls.listClasses.ListData;
import mx.events.ListEventReason;
import mx.events.ListEvent;
import mx.events.DragEvent;
[Bindable]
public var myDragArr:Array=["sumeet","Ashish","Raj","Karuna"]
public var myDropArr:Array= ["group1"];
public var myDropArr1:Array=[]
public var myList:List;
private var count=0;
public static const ITEM_EDIT_END:String = "itemEditEnd"
var event:Event;
public function dragDrop_handler(event:DragEvent)
{
//event.preventDefault()
myDropArr1.push(grid1.selectedItems)
Alert.show(myDropArr1+" event.target")
}
public function dragComplete_Handler(event:DragEvent):void
{
//Alert.show(grid1+"")
}
public function addInstances(event):void
{
count++
myList= new List()
VBOX.addChild(myList);
var myId:String="myList"+count
myList.width=60
myList.height=60
myList.dataProvider="group1";
myList.id=myId
myList.dropEnabled=true
myList.editable=true
myList.addEventListener("itemEditEnd" , itemEditEnd_Handler);
myList.addEventListener("dragDrop",dragDrop_handler)
myList.addEventListener("click",click_handler)
}
public function itemEditEnd_Handler(event:ListEvent):void
{
//Alert.show("Edit End")
myList.editable=false
}
public function click_handler(event:Event)
{
}
]]>
</mx:Script>
<mx:DataGrid allowMultipleSelectionfiltered="true" id="grid1" x="10" y="28" width="231" dragEnabled="true" dataProvider="{myDragArr}" dragComplete="dragComplete_Handler(event)">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
</mx:columns>
</mx:DataGrid>
<!-- <mx:List it id="list1" x="488" y="43" width="122" height="95" dropEnabled="true" dataProvider="{myDropArr}" dragDrop="dragDrop_handler(event)"/> -->
<mx:VBox id="VBOX" x="272" y="28" width="139" height="183">
</mx:VBox>
<mx:Button label="Add" click="addInstances(event)" x="297"/>
</mx:Application>
Regards
Sumeetk
Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail Beta. __._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development | Computer software development | Software design and development |
Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.