Skip to Main Content

APEX 20.2 Tree - Dynamically setting the 'Selected Node Page Item'

JSmydoFeb 8 2021 — edited Feb 9 2021

I have a scenario where I have a Tree region that I would like to refresh based on a report column selection so that I can see the Hierarchy stack upstream and downstream of a given node. I thought that i'd utilize the 'Selected Node Page Item' (SNPI) for this purpose by setting it to the selected node id via a DA and then refreshing the tree region to then redraw the tree with the relevant node selected. It doesn't work and the original value for the SNPI is retained regardless of what I change it to via the DA.
Is this because a treeView('refresh') action does not re-evaluate the session value of the SNPI? Does the tree have to be re-initialized or something? The whole aim is to redraw the tree region without re-loading the page. Does anyone know if what I'm atttempting is achievable? Is there even a way that I could set the selectedNode in the tree via JS? I have looked at the API but it would seem I'd need to trawl the tree manually to find the relevant matching text and then trigger a selection and this seems a pretty inelegant solution. I'd be grateful for any ideas.
UPDATE: I should have said that I used the javascript initilization code provided by John Snyder here:
APEX Tree expand child node conditionally (0 Bytes)So, I'm providing the page item value within this makeNodeAdapter call on instantiation and this is what is not being re-evaluated on refresh of the region: does this makeNodeAdapter only get called on initial load of the page and not on refresh of the region?


Post Details
Added on Feb 8 2021