This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,899 Users
  • 2,269,649 Discussions


Bug: Delete single existing element in Tree (Apex 19.2)


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=

  at Object.javascriptFunction (f?p=107:25:4795512655365::::::1809)

  at Object.da.doAction (desktop_all.min.js?v=

  at Object.da.doActions (desktop_all.min.js?v=

  at l (desktop_all.min.js?v=

  at Object.da.resume (desktop_all.min.js?v=

  at Object.e [as callback] (desktop_all.min.js?v=

  at n (desktop_all.min.js?v=

  at Object.apex.event.trigger.H.success (desktop_all.min.js?v=

  at c (desktop_all.min.js?v=

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?