2 Replies Latest reply on Sep 27, 2006 9:31 AM by amers

    Tree and Drag and Drop

    amers Level 1
      I have a small question on the Drag and Drop using the Tree component.

      private function dragEnterHandlerTree(event:DragEvent):void {

      var dropTarget:UIComponent = UIComponent(event.currentTarget);

      if (event.dragSource.hasFormat('treeItems'))

      {

      // Signal that this data can be dropped onto the target

      DragManager.acceptDragDrop(dropTarget);

      trace("drag accepted.");
      DragManager.showFeedback(DragManager.COPY);
      trace(DragManager.getFeedback());


      var dragItems:Array = event.dragSource.dataForFormat("treeItems");
      }
      }

      now dragItems is an Array, it has the length of 1; but when I look at the information through a trace, it's empty.

      Any ideas on how to get the node's information? I've tried a couple different ways, one way had an issue and it read the tree node to be:

      <label="name" id="data" anotherID="id">

      any ideas?

      thanks!
        • 1. Re: Tree and Drag and Drop
          inlineblue Level 1
          The data is an XML object, so tracing it directly, as in trace(dragItems[0]), will output an empty string since the node doesn't have any content. You can trace dragItems[0].toXMLString() to get the full XML. And since it's an XML object, just use e4x operations to get at the data.

          • 2. Re: Tree and Drag and Drop
            amers Level 1
            thanks muchly!

            I was finally able to get the information and showing the XML helped quite a bit.

            trace("name: " + dragItems .@name);
            trace("ID: " + dragItems
            .@ID);

            After I got the information, I was able to successfully update the information using a web service. Now I'm having some issues on how to refresh the datagrid (since it's in it's own component).

            thanks again!