Tree Drag & Drop problem identifying drop location

Item0
----- Item1
---------- Item11
---------- Item12
..............................<--------
----- Item2
---------- Item21
---------- Item22
----- Item3
---------- Item31
---------- Item32
When I drag Item32 to drop at the location pointed by the
arrow, it can be dropped as :
1). A third child of Item1 or
2). A Second child of Item0
After drop, I need to update the database for Item32's new
parent change.
How can we identify new parent whether it is dropped as Case
1). or Case 2).
Because the calculateDropIndex return the same index(of
Item2) and cannot identify...
Any suggestion?
Thanks

Hi guys,
I ran into the same issue and think I have managed to solve it. Below are the steps I took:
1. In my dragDrop event I grabbed the drop index by using tree.calculateDropIndex(event) and created a bindable variable [dropIndex] to store the index number.
2. I created a separate function [tree_getNewParent] to get the new parent from.
3. In my dragDrop event (I have also tried this with dragComplete) I added a callLater to the function I created in the previous step. I remembered that I had dramas trying to expand items and the solution I found used callLater as the items weren't yet bound. I assume it is the same case here.
4. Finally in the separate function I set tree.selectedIndex to equal the index I stored in the dragDrop event. Then to access the new parent I simply did a tree.selectedItem.parent()!
Mine looks something like this:
[Bindable]
private var dropIndex:Number;
private function tree_dragDrop(event:DragEvent):void{
     var dIndex:Number = tree.calcualteDropIndex(event);
     dropIndex = dIndex;
     callLater(tree_getNewParent);
private function tree_getNewParent():Object{
     tree.selectedIndex = dropIndex; 
     var newParent:Object = new Object();
     newParent = tree.selectedItem.parent();
     return newParent;
Please let me know how you go.
Cheers,
Stu.

Similar Messages

  • Tree drag-drop function

    hello all,
    there is one single tree component in my application.
    XML is dataprovider of that tree.
    e.g
    <node name="Cars" id="1" isparent="true">
    <node name="Audi" id="2" isparent="true">
    <node name="A4" id="3" isparent="false"/>
    <node name="A6" id="4" isparent="false"/>
    </node>
    <node name="Mercedes" id="5" isparent="true">
    <node name="M-Class" id="6" isparent="false"/>
    <node name="R-Class" id="7" isparent="false"/>
    </node>
    </node
    when i drag one node and drop to another node, how can i know the xml value of
    both source & destination node?
    e.g
    we are Dragging 'R-Class' node to 'Audi' node, on dragComplete OR dragDrop
    event, how to get R-Class node id 7 & Audi node id 2 in different variables.
    So we can check some validation of node and perform drag-drop operation.
    Any idea?
    Steve Roger.

    actually what i want to implement is like :
    When drapDrop event complete, i want XML value of both nodes (source & target) in variables.
    Then I will show dialog box having some options & instructions (e.g You wanna Move node OR Copy node to target).
    Depend on user selection, do the operation.
    hope u get application scenario.
    is this possible for tree control using drag drop? if so, then how?
    Please help.
    Thank you,
    Steve Roger.

  • Tree Drag & Drop - Drop Over

    Hi Experts!
    I have a small question.I have a tree control, there are many nodes in it. I have allopwed all Drag and Drop properties, and handle the following events:
    - Drag Starting? to check if the selected node is "valid"
    Using this event I can filter the items what I want to drag.
    The tree D&Drop functionality works fine,
    but I want to filter  where do I want to drop the selected node. For the filtering I use Drag Over event - Coords - Point to row Column - Tag , and check the tag is valid so the drop will be in right place.
    But, when I insert the Drag Over event, and Accepted - set true, the dropping not executes, nothing changes.
    BTW, when I delete this Drag Over event again, the dropping executes well, but I can not filter the place where I want to Insert.
    Please Help
    +++ In God we believe, in Trance we Trust +++
    [Hungary]

    See Attachment
    +++ In God we believe, in Trance we Trust +++
    [Hungary]
    Attachments:
    Test.png ‏23 KB

  • Drag & drop item within Tree not working

    Hi,
    I want to be able to drag & drop items within a tree but
    items cannot move accross branches
    It can only be moved within its branch.
    For this I have a condition in dragDrop(event) handler.
    When i drag item it does not move accross branches which is
    intended but when i drop within its branch
    on a different location,
    the item does
    not get dropped
    Though i have dragMoveEnabled set to true.
    my code looks like this:
    private function onDragDrop(event:DragEvent):void {
    var dropTarget:Tree = Tree(event.currentTarget);
    var node:XML = myTree.selectedItem as XML;
    var p:*;
    p = node.parent();
    if(node.parent().@label != "sameBranch") {
    return;
    } else {
    // drop target.
    Do i need to do anything else...
    Please advice.
    Thanks
    Lucky

    topping up, still did not find a way to do...
    but i have handled all tree events like dragEnter and
    dragDrop as described in the flex doc.
    Has anyone faced a similar issue...

  • Strange Problem Drag & Drop Between Lists

    In the following code, drag & drop is set to copy objects, but when more than one instance of an item exists, only the last item (highest data provider index) item can be selected. Any idea why this is happening, and how to correct this?
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
      creationComplete="init();">
      <mx:Script>
        <![CDATA[
          import mx.collections.ArrayCollection;
          [Bindable] private var srcAC:ArrayCollection = new ArrayCollection();
          [Bindable] private var destAC:ArrayCollection = new ArrayCollection();
          private function init():void{
            srcAC = new ArrayCollection(['Fish', 'Meat', 'Chicken']);
            destAC = new ArrayCollection();
          private function displayData():void{
            trace("****************************************");
            trace("menuList dataProvider:");
            for each(var srcItem:Object in srcAC){
              trace("\t" + srcItem.toString());
            trace("----------------------------------------");
            trace("orderList dataProvider:");
            for each(var destItem:Object in destAC){
              trace("\t" + destItem.toString());
        ]]>
      </mx:Script>
      <mx:HBox>
        <mx:VBox>
          <mx:Label text="Today's Menu" fontWeight="bold" fontSize="14"/>
          <mx:List id="menuList" width="200" dataProvider="{srcAC}"
            dragEnabled="true" dropEnabled="true" dragMoveEnabled="false"
            allowMultipleSelection="true" fontSize="14"/>
        </mx:VBox>
        <mx:VBox>
          <mx:Label text="Your Order" fontWeight="bold" fontSize="14"/>
          <mx:List id="orderList" width="200" dataProvider="{destAC}"
            dragEnabled="true" dropEnabled="true" dragMoveEnabled="false"
            allowMultipleSelection="true" fontSize="14"/>
        </mx:VBox>
      </mx:HBox>
      <mx:Button id="b1" label="Reset Order" click="init();"/>
      <mx:Button label="Display Data Providers" click="displayData();"/>
    </mx:Application>

    Hello
    Actually I have also face this problem in one of my appliocation so have done some work arround for that.
    If we use object of ArrayCollection as 'key-value' (like- {label:'Fish'} ) pair than it work fine.
    srcAC = new ArrayCollection([ {label:'Fish'},{label:'Meat'},{label:'Chicken'}]);
    In case of
    srcAC = new ArrayCollection(['Fish', 'Meat', 'Chicken']);
    If we drop same item two times than list is not identify unique item of the list
    and if we use objet like- {label:'Fish'} than every item is unique for list.
    I m not sure this is right or not but it works fine.
    Also we need to set 'labelField' of list as per object.
    With Regards
    Virat Patel

  • PSE7 with Windows 7 - Drag & Drop Problems

    Hello,
    have some people experince in PSE 7 with OS Windows 7?
    I have some problems with the Drag & Drop function. If I drag a picturce from the explorer into PSE7, PSE7 freeze and need two minutes to come back. Have somebody any idea / solution?
    --> No updates available for the product (PSE7)
    Greetings Daniel

    Hi, It works good for me. can you please make sure that the file you are dragging is not too large or is not currupt. can you please confirm that it is opening fine in other applications like Windows picture viewer?

  • Cannot drag and drop image from Safari to Desktop - drop location is unavai

    Drag and drop an image from Safari 2.0.4 to the Mac OS X 10.4.10 Desktop does not save it. Console says:
    "drop location is unavailable"
    Control click over the image and "Save Linked File to the Desktop" works as expected.
    Any hint most welcome. Thanks.

    Why not simply adjust the link for the image in the Links palette? Certainly could be contained in an action, if need be for duplicating and exporting multiple images...
    Mylenium

  • Drag & Drop, ALV or Table Control to Tree Control

    Hi Experts,
    If i want Drag & Drop feature in ALV or Table Control to Tree Control

    Hi,
      refer to the link below:
    http://help.sap.com/saphelp_46c/helpdata/fr/22/a3f5fbd2fe11d2b467006094192fe3/content.htm
    With luck,
    Pritam.

  • Strange problem with drag&drop!!

    hello i hope u can help me.
    i have a strange problem but not like the other users with drag&drop in Leopard..
    mine is not exactly like this:
    http://discussions.apple.com/thread.jspa?threadID=1198982&tstart=3538
    i can hold left click and move files but when i need to "drop" them at the .app's window the app rejects the file back! (some of the applications not all!)
    what i mean in examples is:
    i cannot drag&drop anything in the VLC's player window but i can inside the vlc's "controller" window
    i cannot drag&drop a picture in preview
    i cannot drag&drop any file in photoshop's new file/empty canvas
    i cannot drag&drop a mp3 file in itunes but i can drag&drop a full album folder(only in playlist,not in the player window)!
    and i can describe more to show u that it's not about vlc or preview or PS problem, but finder's/leopard problem.
    (i thought in the 1st, that it's vlc's problem and i downloaded a lot of versions!)
    all the other programs works well, for example i can drag&drop a video to final cut or motion
    i can do the same in iMovie (at the space it says"drag&drop media here etc)
    and of course i can drag&drop files to desctop,hard disks etc.
    i can copy/paste text etc (i can copy/paste texti can copy/paste texti can copy/paste texti can copy/paste text)
    i am trying to give you an idea, suggest me what else should i try in order to focus where exactly the problem is!
    i hope u give me a solution cause drag&drop is usefull!
    thank you
    in order to help u, i will describe what i tried so far:
    1)repair permissions
    2)trash com.apple.finder
    3)terminal solution like this: (didn't worked)
    sudo su -
    cd /
    rmdir tmp +*(rmdir: tmp: No such file or directory)*+
    ln -s tmp /private/tmp

    alex74d wrote:
    hello and thanks for your reply
    but why you quote only the part of VLC?
    One thing at a time. Occam's razor.
    and why u believe this is normal?
    i am sure that VLC can drag & drop subtitles or the movie in the player window.
    and when i say sure, i mean 100%
    I disagree. I have tried this since reading your post, on all my VLC versions. It does not work.
    You can, however drop a movie onto the VLC icon in the dock. That works fine.
    RealPlayer accepts a file dropped on it. I just checked it.
    Not all apps accept a file on their output window. Usually only the input window.
    i started my windows bootcamp partition before and i saw this works.
    and i remember trying VLC in tiger a lot of years before, this was ok.
    and yes of course it would be also normal to drop a picture in the photoshop canvas.
    so what is not normal here is my problem, if u can help i'm happy if you cannot please don't confuse it more
    (sorry if i sound "unclear", english is not my 1st languange)
    I will check VLC next time I run Tiger and let you know.
    Message was edited by: nerowolfe

  • Drag & Drop kills Tree Change event

    I have a tree that I am dragging from to a HorizontalList.
    Anyway, I have the actual drag and drop working fine. However, my
    tree has a handler for it's change event so that when the selected
    item changes, a web service lookup is initiated. After the drag and
    drop the tree appears to have a different item selected, however
    the change event does not fire. Also if I manually click on the
    same row that already appears selected, the event fires and my
    lookup is kicked off.
    It's like after the drag drop the tree's selected item
    appears selected VISUALLY but the tree does not know it is the
    selected item.
    HELP PLEASE.
    P.S. - I am using Flex 2.01 by the way.

    The trick is not to use the tree drag* properties of the
    control and instead use the DragManager to do custom drag and drop.
    This allows to listen to mouse down events and evaluate
    whether to useDragManager.doDrag() to initiate a drag.

  • Drag from tree to Drop on button

    Hi Expert,
    I want to drag data from a tree and drop it to button.Pls suggest how we do that.
    Please do help.
    Thanks and Regards.
    Swatantra Pathak

    Hi
    Have you checked these programs:
    BCALV_GRID_DND_TREE            ALV Grid: Drag and Drop with ALV Tree                             
    BCALV_GRID_DND_TREE_SIMPLE     ALV GRID: Drag and drop with ALV tree (simple)                    
    Regards
    Neha

  • Disable Drag & Drop in Tree for some nodes

    It is very easy to enable Drag and Drop on Tree controls. How
    do I disable some Nodes from being dragged? I do not need all nodes
    to be draggable.

    The trick is not to use the tree drag* properties of the
    control and instead use the DragManager to do custom drag and drop.
    This allows to listen to mouse down events and evaluate
    whether to useDragManager.doDrag() to initiate a drag.

  • Filmware problems, drag & drop doesnt work anym

    <SPAN>Hiya
    <SPAN>
    <SPAN>I have a problem with connecting my MicroPhoto to load the battery and add new music. I haven't had this before. I connected the player on the same way I always do and I got this 'recovery' screen. I could choose for a few options like: Clean, reboot, install filmware. I disconned and connected a few times but I kept getting it. Also the creative media explorer didnt recognise the player so I couldnt get in the harddisc of the player. Then I decided to install new filmware. I deleted to old filmware and installed the new one (my computer said it was the exact same version) <SPAN>Finally I could get into the harddisc again, but then I had a new problem. I couldn't add any music/files by just dragging and dropping. So I disconnected and connected the player, but its still the same. I can, however, add music with the other way (adding media).
    <SPAN>Somehow the new filmware has blocked the option drag & drop.
    <SPAN>What do I do with this?

    How do you mean one direction? Do you mean making one map and put all the songs in there? I can not add songs in a map. I keep on getting the same message, really bizar.

  • Problem drag/dropping photos to other Apps (e.g. PowerPoint).

    I just got a new camera (FujiFilm FinePix S5700) and the photos from this camera can't be drag/dropped to other apps. If I try it I get the error message "Quick Time and a Tiff decompressor are needed to see this picture"
    That puzzles me because the file info shows the pictures as being jpeg files. If I export the photos somewhere else I can drag/drop them into other apps, but not directly from IPhoto. I have had photos from two other cameras and have not had this problem. Any ideas?

    Craig:
    Try this test. Import a photo from the camera to the desktop first and then import into iPhoto. Now see if that photo can be dragged into another app. They do have a jpg extension on the file name, right?
    Happy Holidays
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Since upgrading to iTunes 10.5.2 Drag&Drop no longer works in iTunes. Has anyone else experienced this problem?

    When I upgraded to iTunes 10.5.2 I lost the ability to Drag&Drop. I started a new playlist and I could only add songs by cut and paste, and once they were on the list I can’t rearrange them in any other order.

    I realized I can't drag and drop either, but I barely have any songs and I've never noticed if this feature was there before 10.5.2. Is this only on a playlist?

Maybe you are looking for