Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1038127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:56:11+00:00 2026-05-16T14:56:11+00:00

I need some combined functionality regarding drag’n’drop between two trees in ExtJS . The

  • 0

I need some combined functionality regarding drag’n’drop between two trees in ExtJS.

The first required feature is very simple and is just the builtin drag’n’drop features isolated to a single tree only.

Standard tree drag'n'drop

The second required feature is that I wan’t the user to be able to drag a node from the left tree and drop it at any node in the right tree.

One way non destructive drag'n'drop

The action should not remove the node from the left tree, thus creating the possibility of dragging the same node from the left tree to multiple places in the right tree.

My question is: Which approach should I take to combine these two functionalities, utilizing the existing possibilities in the TreePanel object without inventing the wheel again? I am not looking for a complete solution (it would be nice though 😉 ), but rather how to handle drag/drop-zones, events and so on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:56:11+00:00Added an answer on May 16, 2026 at 2:56 pm

    Okay. I have been thinking about this some time now, and the following approach seems to work for me 🙂

    I have configured the left tree as this:

    listeners:
    {
        beforenodedrop: function (dropEvent) {
            // Does this node come from the right tree?
            if (dropEvent.source.tree.id !== dropEvent.tree.id) {
                // The node should be discarded.
                dropEvent.dropNode.parentNode.removeChild(dropEvent.dropNode, true);
    
                // The node has been discarded, return drop succeeded.
                dropEvent.dropStatus = true;
                return false;
            }
            return true;
        },  
        nodedragover: function (dragevent) {
            // If the node comes from the right tree, it is allowed to be dropped here.
            if (dragevent.source.tree.id !== dragevent.tree.id) {
                return true;
            }
            // A node from this tree is not allowed to be dropped.
            return false;
        }
    }
    

    The right tree is configured like this:

    listeners:
    {   
        beforenodedrop: function (dropEvent) {
            // Does this node come from the left tree?
            if (dropEvent.source.tree.id !== dropEvent.tree.id) {
                // The node should be cloned and inserted in the right tree.
    
                // Copy the node.
                var node = dropEvent.dropNode; // the node that was dropped
                var nodeCopy = new Ext.tree.TreeNode( // copy it
                    Ext.apply({}, node.attributes)
                );
                // Match the id's.
                nodeCopy.id = Ext.id(null,'newnode') + '_' + node.id;
    
                // Find the right place to put it.
                if (dropEvent.target.parentNode === dropEvent.tree.getRootNode()) {
                    // The node is placed on a folder, thus drop it there.
                    dropEvent.target.appendChild(nodeCopy);
                } else {
                    // The node is placed inside a folder, thus place it in there.
                    dropEvent.target.parentNode.appendChild(nodeCopy);
                }
    
                // The node has been dropped, return okay and stop further process.
                dropEvent.dropStatus = true;
                return false;
            }           
            // Just use the normal builtin drag and drop.
            return true;
        }
    }
    

    Both trees has been set to enable Drag’n’Drop:

    enableDD: true
    

    All leaf nodes have the following configuration:

    allowDrop: true,
    draggable: true
    

    All folders are set to:

    allowDrop: true,
    draggable: false
    

    The conclusion is, that I have chosen to override some of the builtin drag’n’drop methods in the treepanel while still maintaining the builtin functionality.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data from two different sources that I need to combine. Some data
Need some regular expressions help. So far I have my code working to allow
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via
Need some quick advice I am trying to access a object array but I
Need some help with Activerecord Querying in a has_many :through association. Model: Job class
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help to solve this. I have a gridview and inside the gridview
Need some guidance figuring out what went wrong. I've been using mysql, phpmyadmin for
Need some help with this problem in implementing with XSLT, I had already implemented
Need some help gathering thoughts on this issue. Our team is moving ahead with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.