Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.4K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 442 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
How to make Drag&Drop in tree widget working? (Apex 19.2)

Hello
I'm working with the tree widget of Apex to display a tree after page load (Apex 19.2). This is all working fine. Now I want to allow the users to drag&drop tree nodes inside the tree. I checked/followed the doc of Apex 19.2 API:
Enable drag&drop in treeView:
var tree = $( "#HIERARCHYTREE_tree" );
// Get adatapter data
var adapter = tree.treeView( "getNodeAdapter" );
// Get drag option state
console.log (tree.treeView( "option", "dragAndDrop" ) );
// Output: false
// Enable drag in treeView
tree.treeView( "option", "dragAndDrop", true );
// Check if it's set now
console.log (tree.treeView( "option", "dragAndDrop" ) );
// Output: true
-> So far, so good in/for treeView. Furthermore the doc mentions this:
If true drag and drop is supported. The treeNodeAdapter must also support drag and drop.
Ok, switching to to AdapterNode documentatin where I can't find drag related setter functions, only two getter functions:
- allowDrag (true if allowed, else false)
- dragOperations (type of possible operations)
I can check the states:
allowDrag shows me "false", dragOperations shows me {normal: "move", ctrl: "copy"} on any node in the tree.
Questions: Now I wonder how I can enable the drag operation on Adapter level after the tree was generated? How can I remove the "copy" operation (I only want to allow "move")?
As I need to update the tree in the background in the DB as well I need to be able to react on move-drag operations. Based on the documentation I tried this (similar way as I react on selectionChange when user clicks on an element in the tree and the event fires as it should):
// Page load event:
var tree = $( "#HIERARCHYTREE_tree" );
//The way I have implemented selectionChange and is working:
tree.on( "start", function( event, ui ) {
alert ("drag start");
} );
-> Uncaught TypeError: apex.da.initDaEventList is not a function
// Trial 2:
tree.on( "treeviewstart", function( event, ui ) { // also tried 'treeviewStart' and just 'start' instead of 'treeviewstart'
alert ("drag start");
} );
In case of 'Trial 2' nothing happens (no alert message) while dragging.. I don't know how the drag visually should look like if there is any (do I see the grabbed tree moving?) or it's simply not working/firing because it's not activated on TreeNodeAdapter level?
I also tried to find any example of drag&drop operation in the Internet but couldn't find them for Apex. So before spending more hours on trying to make it work I come to this place in hope someone can confirm me drag&drop operation is working in Apex tree widget and even better: a simple code sample.
Thank you
John
Answers
-
John,
I have a similar use case and am struggling with it. Where you able to solve the issue?
Dhawal
-
No. I've created some separate functionality where the user can select what element to move and then where to move. That was also followed by some hassle. After knowing all that I would have chosen a third party hierarchy plugin.
-
John,
Thanks for sharing your experience.
Regards
Dhawal