i have a blog post on this... includes code http://axel.cfwebtools.com/index.cfm/2007/9/7/Using-a-tree-with-drag-and-drop-FROM-a-grid
--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote: > > DataGrids have linear data and place into the dragsource a format called > "items". A tree takes hierarchical data and expects a format called > "treeItems". You can customize the drop handling on the tree. It > requires using preventDefault() to block default tree behavior and > inserting the "items" data yourself. > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Luis Torres > Sent: Monday, October 01, 2007 11:12 AM > To: [email protected] > Subject: [flexcoders] Dragging from Datagrid to Tree > > > > This has been asked several times, but I haven't seen an answer yet. > I'm trying to drag an item from a datagrid to a tree. From datagrid > to datagrid works fine, but for some reason, dragging to a tree won't > accept the dragdrop, even when the dragManager is told to accept it. > I'm sure there's something stupid I'm missing, but I just can't see > it. Here's a simple sample that demonstrates what I'm talking about. > > <?xml version="1.0"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml > <http://www.adobe.com/2006/mxml> " width="100%" > height="100%" borderStyle="solid" > > > <mx:Script> > <![CDATA[ > import mx.controls.Alert; > import mx.managers.DragManager; > import mx.events.DragEvent; > private function doDragEnter(rEvent:DragEvent):void { > DragManager.acceptDragDrop(Tree(rEvent.currentTarget)); > } > > private function doDragDrop(rEvent:DragEvent):void { > Alert.show('dropped'); > } > ]]> > </mx:Script> > > <mx:ArrayCollection id="treeData1"> > <mx:Object label="cat 1" children="{treeData2}"/> > <mx:Object label="cat 2" children="{treeData3}"/> > <mx:Object label="cat 3" children="{treeData4}"/> > </mx:ArrayCollection> > > <mx:ArrayCollection id="treeData2"> > <mx:Object label="cat 1a"/> > </mx:ArrayCollection> > > <mx:ArrayCollection id="treeData3"> > <mx:Object label="cat 2a"/> > </mx:ArrayCollection> > > <mx:ArrayCollection id="treeData4"> > <mx:Object label="cat 3a" /> > </mx:ArrayCollection> > > <mx:ArrayCollection id="listData"> > <mx:Object label="oc1"/> > <mx:Object label="oc2"/> > </mx:ArrayCollection> > > <mx:HBox width="100%"> > <mx:Tree id="tr" dataProvider="{treeData1}" showRoot="false" > labelField="label" > dropEnabled="true" dragEnter="doDragEnter(event)" dragEnabled="true" > width="100%" dragDrop="doDragDrop(event)"/> > <mx:DataGrid id="dg" dataProvider="{listData}" dragEnabled="true" > dropEnabled="true" width="100%"> > <mx:columns> > <mx:DataGridColumn dataField="label"/> > </mx:columns> > </mx:DataGrid> > </mx:HBox> > </mx:Application> >

