Discussions
Categories
- 197.1K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.7K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 555 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.3K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 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
- 466 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Bug: Delete single existing element in Tree (Apex 19.2)

Hello
It seems that deleting an element in a Tree (Widget) doesn't work if that element is the only one:
// Get tree
var tree = $( "#HIERARCHYTREE_tree" );
// Get tree selection
var selection = tree.treeView( "getSelection" );
// Remove chosen element from Hierarchy Tree
var adapter = tree.treeView( "getNodeAdapter" );
var nodesSelected = tree.treeView( "getNodes", selection );
// Ugly workaround to make the deleteNode function happy: add an empty array to selected node if there is none
nodesSelected[0].children = nodesSelected[0].children || [];
// Remove node from tree
adapter.deleteNode(nodesSelected[0], function(){
tree.treeView('refresh'); // And finally the tree must be refreshed to see the node removed
}, true);
Even tough I try to tell the deleteNode function there is a children array it fails:
Uncaught TypeError: Cannot read property 'children' of null
at Object.deleteNode (widget.treeView.min.js?v=19.2.0.00.18:2)
at Object.javascriptFunction (f?p=107:25:4795512655365::::::1809)
at Object.da.doAction (desktop_all.min.js?v=19.2.0.00.18:21)
at Object.da.doActions (desktop_all.min.js?v=19.2.0.00.18:21)
at l (desktop_all.min.js?v=19.2.0.00.18:21)
at Object.da.resume (desktop_all.min.js?v=19.2.0.00.18:21)
at Object.e [as callback] (desktop_all.min.js?v=19.2.0.00.18:22)
at n (desktop_all.min.js?v=19.2.0.00.18:13)
at Object.apex.event.trigger.H.success (desktop_all.min.js?v=19.2.0.00.18:13)
at c (desktop_all.min.js?v=19.2.0.00.18:2)
So I have no clue where else the deleteNode function needs "children" in the structure. The same workaround works for adding a node:
...
-- Required, else error message of missing children (if there are no children, Apex does not append an empty array)
nodesSelected[0].children = nodesSelected[0].children || [];
adapter.addNode(nodesSelected[0], 0, nodeLabel, {id: nodeIdSelected, children: [], icon: "icon-tree-folder"}, function(){
tree.treeView('refresh'); // And finally the tree must be refreshed to see the new node
});
Anyone knows a workaround to get that fixed?