Nevermind, I figured it out- I need to select the row before I drag
onto it.
On Oct 22, 2007, at 12:19 PM, Davy Strube wrote:
I'm trying to write an AIR app with a DataGrid that will accept a
drag and drop of a file from my desktop.
So far, I've gotten the DataGrid to know when a file is dropped on
it and to display the file name in an Alert.
But I'd also know the particular row that the file was dropped on.
Even better if I can know which column of which row, but first is
to know the row.
Here is my source so far:
======================
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void{
dgPosts.addEventListener
(NativeDragEvent.NATIVE_DRAG_ENTER,dragEnterred);
dgPosts.addEventListener
(NativeDragEvent.NATIVE_DRAG_DROP,dropped2);
}
private function dragEnterred(event:Event):void{
DragManager.acceptDragDrop(dgPosts);
}
private function dropped2(event:NativeDragEvent):void{
var array:Array = event.clipboard.getData
(ClipboardFormats.FILE_LIST_FORMAT) as Array;
for each (var file:File in array){
Alert.show("file: "+file.name +" on row
"+dgPosts.selectedItem);
}
}
]]>
</mx:Script>
<mx:XMLList id="employees">
<employee>
<name>Christina Coenraets</name>
<phone>555-219-2270</phone>
<email>[EMAIL PROTECTED]</email>
</employee>
<employee>
<name>Joanne Wall</name>
<phone>555-219-2012</phone>
<email>[EMAIL PROTECTED]</email>
</employee>
</mx:XMLList>
<mx:Panel width="100%" height="100%"
horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:DataGrid id="dgPosts" height="80%" width="250"
dataProvider="{employees}" rowHeight="60" y="31" x="10"
>
<mx:columns>
<mx:DataGridColumn id="a" dataField="name"
headerText="Name"/>
<mx:DataGridColumn id="b" dataField="phone"
headerText="Phone"/>
<mx:DataGridColumn id="c" dataField="email"
headerText="Email"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:WindowedApplication>
-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the
subject line
For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------