Reimius
Reimius

Reputation: 5712

Drag and Drop between trees and within one of the trees

I have two trees in Extjs 4.1 with the drag and drop plugin enabled. The user can drag and drop between these trees. Here is the only relevant configurations for these trees in this situation is the viewConfig:

tree 1:

viewConfig:{
            plugins: [
                new PmProjectManagement.viewEdit.AvailableCriteriaTreeViewDragDrop({
                    allowContainerDrop: true,
                    allowParentInsert: false,
                    expandDelay: 30000,
                    dropGroup: "secondGridDDGroup",
                    dragGroup: "firstGridDDGroup"
                })
            ]
        }

tree 2:

viewConfig:{
            plugins: [
                new PmProjectManagement.viewEdit.ViewConfigTreeViewDragDrop({
                    allowContainerDrop: true,
                    allowParentInsert: false,
                    expandDelay: 30000,
                    dropGroup: "firstGridDDGroup",
                    dragGroup: "secondGridDDGroup"
                })
            ]
        }

Right now I can drag and drop from one tree to another just fine, but what I really want is to be able to drag from tree 1 to tree 2, from tree 2 to tree 1, AND within tree 2. I am having trouble with the draggin around in tree 2 because the ddGroup is set to the other tree. I also need tree 1 to not be able to drag around within it. Does anyone have a suggestion as to go about this? The only solution I can think of involves using overrides on the isValidDropPoint function and removing the ddGroup qualifiers, but I would really like a more elegant approach to this.

Upvotes: 2

Views: 1623

Answers (1)

babinik
babinik

Reputation: 648

ddGroup should be the same for both trees.

In ext 4.2 you have the nodedragover event notifying the Ext.tree.View during dragging. This event is going from the Ext.tree.ViewDropZone#isValidDropPoint.

So in the ext 4.2 you just need to processing this event and decide drop is allowed or not, event firing gives you a lot of information, so you can found out that is dragging and which tree is used the event description.

dragData parameter contains "view" property from which you can take the tree - drop destination tree, like dragData.view.panel.

In ext 4.1 you are right there was no the view notifications, guys from sencha even placed a todo marker that this must be implemented in the new version. And yes you can extend the Ext.tree.ViewDropZone and firing kind of event to notify the view about the dragging over (something similar to 4.2). Also you need to extend the Ext.tree.plugin.TreeViewDragDrop plugin to inject there your's just extended Ext.tree.ViewDropZone. It is just overriding onViewRender method of the plugin and use your's just extended drop zone.

Then use new plugin. Another way just override the Ext.tree.ViewDropZone to be applied everywhere in the application.

IMHO you do no need change the dd groups, all you need is just processing the nodedragover in 4.2 of some kinda of implementation.

Upvotes: 1

Related Questions