Skip to Main Content

How to access Treeview by Javascript?

John like many othersJul 29 2020 — edited Aug 7 2020


I have successfully created a hierarchy tree with the Treeview widget. On loading the page I can see the structure. This can change in the background so the user should be able to refresh it. In the documentation I've found the r"efresh" option::

$( "#HIERARCHYTREE" ).treeView( "refresh" );

So when the user presses a button I simply want the treeview refreshed. Instead of I get this error message:

desktop_all.min.js?v= Uncaught Error: cannot call methods on treeView prior to initialization; attempted to call method 'refresh'

    at Function.error (desktop_all.min.js?v=

    at HTMLDivElement.<anonymous> (desktop_all.min.js?v=

    at Function.each (desktop_all.min.js?v=

    at k.fn.init.each (desktop_all.min.js?v=

    at k.fn.init.a.fn.<computed> [as treeView] (desktop_all.min.js?v=

    at Object.javascriptFunction (f?p=107:25:106888120606339::::::246)

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

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

    at HTMLButtonElement.<anonymous> (desktop_all.min.js?v=

    at Function.each (desktop_all.min.js?v=

I assume the selector is correct. I set the value HIERARCHYTREE to the Static ID of the region "Widget", which holds the widget. Everything is there to rebuild the tree (no processes are going on). The refresh is triggered by a simple button (onclick). Any other try to access the treeview shows the same error message, i.e.:

var test= $("#HIERARCHYTREE").treeView("getExpandedNodeIds");

I couldn't find anything in the documentation that I'm doing wrong. I thought the simple access should be enough to refresh the tree view.

-> Working with Apex 19.2

Any help is appreciated!

Post Details
Added on Jul 29 2020