Discussions
Categories
- 385.5K All Categories
- 4.9K Data
- 2.5K Big Data Appliance
- 2.4K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 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
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 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?