[CLOSED] DragDrop in treepanel using TreeViewDragDrop plugin

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] DragDrop in treepanel using TreeViewDragDrop plugin

    Hi team,

    Q1. I am trying to drag and drop on the treepanel ext.net 2. I have two treepanels source and destination. While dropping a node into destination, It should asks the confirmation saying that "The node you are copying has its children as well. Do you want to copy children also?", if user clicks on yes, then the node should be dropped(it is default behavior I think), otherwise parent node only should be dropped into destination excluding its children. How do I achieve this in BeforeDrop event?

    Q2. How do I maintain the same hierarchy in the destination treepanel while dropping? For example, node1, node2 are parent nodes in the left treepanel and they have their own children. It shouldn't allow us to drop node1 and its children into node2 and its children.

    Thank you.
    Last edited by Daniil; May 02, 2013 at 10:46 AM. Reason: [CLOSED]
  2. #2
    Hi @pawangyanwali,

    Quote Originally Posted by pawangyanwali View Post
    Q1. I am trying to drag and drop on the treepanel ext.net 2. I have two treepanels source and destination. While dropping a node into destination, It should asks the confirmation saying that "The node you are copying has its children as well. Do you want to copy children also?", if user clicks on yes, then the node should be dropped(it is default behavior I think), otherwise parent node only should be dropped into destination excluding its children. How do I achieve this in BeforeDrop event?
    I think it is possible using "dropHandler". Please read the docs article here.
    http://docs.sencha.com/ext-js/4-1/#!...ent-beforedrop

    Quote Originally Posted by pawangyanwali View Post
    Q2. How do I maintain the same hierarchy in the destination treepanel while dropping? For example, node1, node2 are parent nodes in the left treepanel and they have their own children. It shouldn't allow us to drop node1 and its children into node2 and its children.
    I think it is possible overriding the isValidDropPoint function. Here is an example. It is not exactly what you need, but demonstrates the idea how to manage it.
    http://forums.ext.net/showthread.php...ll=1#post90551
  3. #3

    DragDrop in treepanel using TreeViewDragDrop plugin

    Hi Daniil,

    Regarding the Q1, if I use dropHandler, that's fine we can show the confirmation message but question is, if I use "dropFunction.processDrop();" it is dropped along with its children. But I don't need children, I need to copy only the parent node. Can you please help me to copy only parent node even if it has children.

    Thank you.
  4. #4
    I meant that there should be a possibility to override the default processDrop function.
  5. #5
    Hi Daniil,

    I am new to ext.net. Can you please provide me some example about how to override processDrop function?


    Thank you
  6. #6
    Example
    <ext:TreeView runat="server">
        <Plugins>
            <ext:TreeViewDragDrop />
        </Plugins>
        <Listeners>
            <BeforeDrop Handler="dropFunction.processDrop = yourHandler;" />
        </Listeners>
    </ext:TreeView>
    A default handler is:
    function () {
        me.invalidateDrop();
        me.handleNodeDrop(data, me.overRecord, me.currentPosition);
        dropHandled = true;
        me.fireViewEvent("drop", node, data, me.overRecord, me.currentPosition);
    }
    Last edited by Daniil; Dec 21, 2012 at 6:36 AM.
  7. #7
    You may be interested to look at this example.
    https://examples2.ext.net/#/TreePane...om_Drop_Logic/
  8. #8

    Validating Child Nodes copy

    In OnBeforeDrop function, what I have done is if the node has child nodes it asks user if he wants to copy child nodes along with it too, if the user clicks on NO, then I have implement this code snippet
    data.records[0].childNodes.copy=false
    dropFunction.processDrop();
    Then in OnDrop function, I am checking if the childnode copy property of recently added node's is set to be false and if it is false I am trying to remove them one by one by using following code snippet

    if (data.records[0].childNodes.copy == undefined) {
            for (var x = 0; x < data.records[0].childNodes.length; x++) {
                data.records[0].getChildAt(x).destroy();
            }
        }
    But this one is not working.

    What I have also figured out that, though I have set the childnode copy property is set to false in OnBeforeDrop function, it is set as undefined in OnDrop function.

    Am I missing something??? It is urgent.
  9. #9
    Hi @pawangyanwali,

    Pleaыу provide a test case.
  10. #10
    var onBeforeDrop = function (node, data, overModel, dropPosition, dropFunction) {
        //allow copy of nodes. it overrides the move functionality, 
        //so that even after moving to another treeview it keeps the node is source treeview as well
        data.copy = true;
        //show the confirmation message, if the node has children.
        var isLeaf = record.leaf;
        if (!isLeaf) {
            //wait until confirmation complete
            dropFunction.wait = true;
            Ext.Msg.confirm({
                title: 'Confirm',
                msg: "Do you want to copy children also?",
                buttons: Ext.MessageBox.YESNO,
                fn: function (btn) {
                    if (btn == 'no') {
                        debugger;
                        data.records[0].childNodes.copy = false;
                        dropFunction.processDrop();
                    }
                }
            });
        }
        //return true;
    };
     
    function OnDropNode(node, data, overModel, dropPosition) {
        debugger;
        if (data.records[0].childNodes.copy == undefined) {
            for (var x = 0; x < data.records[0].childNodes.length; x++) {
                data.records[0].getChildAt(x).destroy();
            }
        }
        return true;
    };
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] TreeViewDragDrop plugin on over event
    By Leonid_Veriga in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 21, 2012, 6:39 AM
  2. DragDrop item information from TreePanel
    By Dominik in forum 2.x Help
    Replies: 1
    Last Post: Jun 01, 2012, 9:31 AM
  3. Replies: 1
    Last Post: Apr 24, 2012, 10:27 AM
  4. DragDrop From Grid To Tree
    By bullzzeye in forum 1.x Help
    Replies: 2
    Last Post: Jan 08, 2012, 4:23 AM
  5. [CLOSED] Plugin to display button after node name in treepanel
    By bakardi in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 26, 2011, 7:49 PM

Tags for this Thread

Posting Permissions