Hi Guys
I am trying to drag contents of one list and drop it into the second List.
I am having issues that first list has values from XML List Collection
and only i need is the 'id' attribute of the XML and I am successful
in getting XML List in 1st list. I am using HTTP Service. Now my
problem is that when i am trying to drag and drop the fields from
first list it puts filed in the second list with [object,object]. I am
using array to grab values from 1st list. I have attached the code.
Anyone has any idea where I am messing things. To me it looks like
casting problems. Please let me know how would I fix this issue as I
only need the same field from one list to other.
Thanks a lot for you help guys
Anuj
/*My Code*/
//First List
[Bindable]
public var _selectedCameras:List=new List();
_selectedCameras.dragEnabled=true;
_selectedCameras.dataProvider=devicesCollection;
_selectedCameras.labelField="@id";
//Second List
var _selectCameras:List=new List();
_selectCameras.dragEnabled=true;
_selectCameras.dropEnabled=true;
_selectCameras.dataProvider=new ArrayCollection();
_selectCameras.labelField="@id";
_selectCameras.dataProvider=new
ArrayCollection();
_selectCameras.labelField="@id";_selectCameras.addEventListener(DragEvent.DRAG_DROP,onListDragDrop);
//Result of the From the data base
private function devicesXMLHandler(event:ResultEvent):void
{
devicesList = event.result.device;
devicesCollection = new XMLListCollection(devicesList);
}
<!--Calling deviceXML Handler-->
<mx:HTTPService id="devicesXML" method="GET" resultFormat="e4x"
url="http://10.80.3.56:8182/config/devices"
result="devicesXMLHandler(event)" showBusyCursor="true"/>
//Calling Function for Drop Manager
private function onListDragDrop(event:DragEvent):void
{ if(event.dragSource.hasFormat("items"))
{ event.preventDefault();
event.currentTarget.hideDropFeedback(event);
var dropTarget:List=List(event.currentTarget);
var itemArray:Array=event.dragSource.dataForFormat("items") as Array;
var alrt:Alert=Alert.show(itemArray.toString());
//Copy the new Dragged data into a new Object
var tempItem:Object={label:itemArray[0].label,data:itemArray[0].data};
//Get the drop location in the destination
if(dropTarget !=null)
{
var dropLoc:int=dropTarget.calculateDropIndex(event);
}
if((tempItem!=null) && (dropTarget!=null))
{
//Add the new object to the drop target
IList(dropTarget.dataProvider).addItemAt(tempItem,dropLoc);
}
}
}