Welcome, Guest. Please login or register.
Did you miss your activation email?
08 Sep 2010, 03:54:02 UTC
Forum home
+  flexdeveloper.eu Forum
|-+  Flex and ActionScript 3.0
| |-+  Flex 3 Framework (Moderators: JMWhittaker, Jan K, thewarpedcoder, James)
| | |-+  drag drop issue, drag XML data from datagrid to list
« previous next »
Pages: [1] Print
Author Topic: drag drop issue, drag XML data from datagrid to list (Read 838 times)
Jens
Newbie FD
*
Posts: 8


« on: 13 Mar 2010, 12:06:38 UTC »

HI,

 
I have with success made a custom dragdrop from a datagrid to a list.

 
First it was simple guest-names in the datagrid. But now I have loaded a guestlist to the datagrid from XML. The names only are showing in the datagrid, but when I drag and drop to the List, all of the XML for a choosen guest drops on the list..

 
XML looks like this, and all of that is being displayed in the list after a drop:


 
<bemyguests>

<guest id="1">

<name>Poul</name>

<lastname>Jensen</lastname>

<adress>Platanvej 4</adress>

</guest>

..

..

 
I am only interessted in getting the name 'Poul' dropped on the list.. Where do I adjust that so it does not just take bulk data to the list.

 
Is it in the dragsource somehow?

 
best regards

jens
Logged
flexy
flexdeveloper.eu
Guru/Addict FD
*****
Posts: 3,204


Recovering Coffee Addict & Adobe Expert


WWW
« Reply #1 on: 13 Mar 2010, 13:18:43 UTC »

Correct, it's all inside the DragSource of your DragEvent. Most list controls expose the rows of items within them as "items", so you check that the dragSource data has items, then you can reference them by their property names:

Code:
if( event.dragSource.hasFormat( "items" ) )
 {
       var sourceObject:Object = event.dragSource.dataForFormat( "items" );
       mx.controls.Alert.show( sourceObject.name );
}
Logged

Jens
Newbie FD
*
Posts: 8


« Reply #2 on: 13 Mar 2010, 14:52:32 UTC »


thanks.. but the alertbox is empty..
tried with guest.name too, but empty.

How do the dragsource store my data...? When I drag, ALL of the XML for that guest follows allong. Does the dragsource consider all the xml-elements of the guest, as one chunk of string maybe? and therefor does not recognize it as elements/Items? 

Logged
flexy
flexdeveloper.eu
Guru/Addict FD
*****
Posts: 3,204


Recovering Coffee Addict & Adobe Expert


WWW
« Reply #3 on: 14 Mar 2010, 12:25:25 UTC »

When you drag from a DataGrid you're dragging an entire row of data, not an individual cell. The dragSource will contain the data for that whole row.

Have a read of this old post from 2006: http://www.flexdeveloper.eu/forums/actionscript-3-0/drag-and-drop/
Logged

Jens
Newbie FD
*
Posts: 8


« Reply #4 on: 14 Mar 2010, 16:45:52 UTC »

..hmmm

actually, there is only one column in the datagrid, by default this shows the name..

datagrid: dataProvider="{guestservice.lastResult.guest}

So the datagrid just shows the first information from the XML, while the drop to the list, reveals it all, and dosen´t seem to get split in items?

Maybe the load approch from XML to datagrid is wrong? But it shows only the name as supposed to. Then I see the additional data else where.. another story...
Logged
Jens
Newbie FD
*
Posts: 8


« Reply #5 on: 14 Mar 2010, 17:25:01 UTC »


datagrid does not show name automatic of course, its datafield is set to "name" and therefor I do not get that this don´t work. I have looked through everything, it should be quite simple, but the alert is just plain...
Logged
Jens
Newbie FD
*
Posts: 8


« Reply #6 on: 14 Mar 2010, 18:23:22 UTC »

Hi again,

I tried to run the code you linked to...

in the code it says.. "I've switched default drag\drop support (dropEnabled = false), so DataGrid dont use stuff on it's own."

But it does not work without setting dragEnabled="true" in datagrid.

Then I tried with some data in a dataprovider directly in datagrid, and loading my XML, in both cases the same problem, and empty Alertbox, like in my own example..

Do you know what could be wrong...

Logged
Pages: [1] Print
« previous next »
Share this on: Twitter Twitter Del.icio.us del.icio.us Digg Digg
Jump to:

©2006-2010 Flexdeveloper.eu/Jodie O'Rourke. All rights reserved.
Adobe®, Adobe® Flash™, Adobe® AIR™ and Adobe® Flex™ are registered trademarks of Adobe Systems Incorporated in the United States and other countries. All rights reserved.

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC