1. #1
    Ext User
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    66
    Vote Rating
    0
    IGx89 is on a distinguished road

      0  

    Default Dragging tree nodes onto leaf nodes?

    Dragging tree nodes onto leaf nodes?


    Imagine you have a tree panel showing a file system. Now, imagine you see some empty folders and want to move some files into them. How can that be done using drag and drop? It's a seemingly relatively simple task, but so far I'm clueless as to how to set up my tree panel to allow that .

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,169
    Vote Rating
    323
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Have you looked at examples? There are draggable tree examples and code of these examples is available too in the Learn/API and Examples section.

  3. #3
    Ext User
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    66
    Vote Rating
    0
    IGx89 is on a distinguished road

      0  

    Default


    Of course . I've also mucked around in Ext's source code a bunch too, to no avail. There aren't any examples, in the documentation or the forums, that allow nodes to be dragged onto leaves, either. This is a necessary feature for me, so worst case I'll have to hack it in myself.

  4. #4
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,169
    Vote Rating
    323
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    I don't know if this is possible but:

    Could you listen to nodedragover and beforenodedrop events? First to show user proper drop enabled indicator and second to turn leaf into node before the drop.

    Just idea. Never tried.

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    8
    Vote Rating
    0
    chun499 is on a distinguished road

      0  

    Default


    check out my solution,
    http://extjs.com/forum/showthread.php?t=5732

    I extend the tree so when u create the TreeNode, set "leaf:false", put it into the tree and expand it, it will stay a folder even it is empty. I didn't try but if it is a folder, then u can drop thing to it.

  6. #6
    Ext User
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    66
    Vote Rating
    0
    IGx89 is on a distinguished road

      0  

    Default


    Thanks for the replies; they helped point me towards the fix . My solution was to make the following modification to Ext.tree.TreeDropZone:
    Code:
        getDropPoint : function(e, n, dd){
            var tn = n.node;
            if(tn.isRoot){
                return tn.allowChildren !== false ? "append" : false; // always append for root
            }
            var dragEl = n.ddel;
            var t = Ext.lib.Dom.getY(dragEl), b = t + dragEl.offsetHeight;
            var y = Ext.lib.Event.getPageY(e);
    -       var noAppend = tn.allowChildren === false || tn.isLeaf();
    +       var noAppend = tn.allowChildren === false;
            if(this.appendOnly || tn.parentNode.allowChildren === false){
                return noAppend ? false : "append";
            }
            var noBelow = false;
            if(!this.allowParentInsert){
                noBelow = tn.hasChildNodes() && tn.isExpanded();
            }
            var q = (b - t) / (noAppend ? 2 : 3);
            if(y >= t && y < (t + q)){
                return "above";
            }else if(!noBelow && (noAppend || y >= b-q && y <= b)){
                return "below";
            }else{
                return "append";
            }
        },
    That one little change (denoted in diff style by the -/+) is all that is needed for the proper functionality, though to fix a couple UI glitches you'll need to apply the fixes I posted in the following bug reports:
    TreePanel drag/drop bug
    Ext.data.Node bug moving between children/no_children states

    To avoid changing the core code or creating new classes, you can make those 3 changes very easily by using Ext.override .

  7. #7
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,169
    Vote Rating
    323
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Thanks a lot for sharing. I appreciate very much the way you handle and post bugs. Explain, show cause and propose solution. Fantastic !


  8. #8
    Ext User
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    66
    Vote Rating
    0
    IGx89 is on a distinguished road

      0  

    Default


    No problem; I interned a couple summers at Adobe working on a big project where I'd be submitting and fixing bugs quite often, so I've learned what makes (and don't make) good bug reports .

    FYI, thanks to a vague hint by Jack I've found an even cleaner way to get the desired functionality: set all nodes to leaf=false, and all leaves (according to the CS and TreePanel definitions of leaves, nodes with no children) to expanded=true and children=empty array (not null!). With that, you don't need the above-mentioned fix or the "Ext.data.Node bug moving between children/no_children states" fix, though my TreePanel drag/drop bugfix is still needed.

  9. #9
    Sencha User
    Join Date
    Feb 2008
    Posts
    107
    Vote Rating
    0
    JDevloper is on a distinguished road

      0  

    Default


    Hi ,

    Am seeing this problem still in extjs 4.0.5 ,Is it fixed,any Workaround....

    Thanks

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar