Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

APEX Tree. Keep focus on expanded leaf node.

697698May 1 2009 — edited Dec 7 2009
How do I prevent my tree from jumping back to the top when I expand a leav node that is below the screen scroll. I have a single parent of CORP with about 30 leaf nodes as its direct children. I have to scroll down to expand a node towards the bottom of the list. When I scroll down and expand, the page refreshes and jumps back to the top so now I have to scroll down again to expand the next node, etc. My current Tree Qurey is like

select CHILD_ID id,
PARENT_ID pid,
CASE WHEN CHILD_ID = :P23_TARGET THEN
CASE WHEN :P23_STATUS = 'Target Up' THEN
'<span styl="color:green;">' || ITEM_NAME || '</span>'
ELSE ITEM_NAME
END
ELSE
ITEM_NAME
END name,
'f?p=&APP_ID.:23:'||:SESSION||'::NO::P23_TARGET:'||CHILD_ID link,
null a1,
null a2
from CORP_SVR_HRCHY_VW
This post has been answered by ATD on May 5 2009
Jump to Answer

Comments

ATD
Hi,

You have to use the Anchor ID functionality of a browser - this allows you to add #id to the end of the url where id refers to the id attribute of the item that should receive the focus when the page is reloaded.

As an example: [http://apex.oracle.com/pls/otn/f?p=33642:200]

This, of course, requires a bit of setting up, but is easily doable.

For this example, my SQL statement for the tree is:
SELECT 1 ID, NULL PID, 'Top' NAME, NULL LINK, NULL A1, NULL A2 FROM DUAL
UNION ALL
select "EMPNO" id, 
       1 pid, 
       "ENAME" name, 
       'f?p=' || :APP_ID || ':200:' || :APP_SESSION || '::::P200_EMPNO:' || EMPNO || '#node' || EMPNO link, 
       'node' || EMPNO a1, 
       null a2 
from "#OWNER#"."EMP"
You will note that the URL contains *'#node' || EMPNO* at the end of the link - for an EMPNO of 1234, this would add *#node1234* to the end of the URL. You will also note that I've added *'node' || EMPNO* to the A1 column - whatever I add into this column becomes available for use in the output by referencing it as #A1# in the template. On the tree's template definition, wherever there is an A tag, I've included:
ID="#A1#"
as an attribute of the tag. For example, on the "Name Link Anchor Tag" setting, I have:
&lt;a href="#LINK#" ID="#A1#"&gt;#NAME#&lt;/a&gt;
and, wherever #A1# appeared outside of an A tag, I have removed it (otherwise, the "node1234" text would appear at that point in the page).

Andy
697698
Hi, Thank you for the help thus far, I think we are getting close.

I'm having two problems with this solution. The node1234 is being appended to my ITEM_NAME at each node showing up on the page. I just want the item name to display without the node123 appended to it.

Secondly, my tree has multiple levels. As I drill down expanding each level below the top of the scroll area the anchor does not work because I'm not clicking the node itself, I'm clicking the + to expand it. It then goes right back to the top leaving my newly expanded leaf below the scroll again. So then I have to scroll down to expand my next node etc.
697698
OK, I see what I did wrong as far as the node1234 being displayed and I've fixed that. but I still need an anchor related to expanding the node rather than clicking on the link. I in fact, do not need a link at all in this particluar case, I've only included it from another page where I have a tree to display a node in colored text when it is clicked based on the value of a hidden computed value elsewhere on the page.

Thanks
ATD
Hi,

The images on the tree do have their own links, but you can update these to include the #node1234 text.

On your tree's definition, in most of the template settings, you should see something like:
href="#DRILL_DOWN#" 
This is where the image link is placed. Update all of these to:
href="#DRILL_DOWN#::::##A1#" 
I've updated by example to do this: [http://apex.oracle.com/pls/otn/f?p=33642:200]

Andy
697698
Thanks, that's exactly what I was tinkering with (the #DRILL_DOWN#) after your original post was not quite working for me, but I could not quite figure out how to make that anchor respond. Now it is working. Thanks again!
697698
Also, based on your example, how do you get that tree to have its own scroll area within the page?! I did not realize you can do that and it would be perfect for my app.
ATD
Answer
You're welcome!

It actually took me a while to work out what to do as well :D

Andy
Marked as Answer by 697698 · Sep 27 2020
591751
Add

<!-- <div style="height:450px; overflow-y:scroll;"> -->

to a "Before tree" box

and

<!-- </div> -->

to a "After tree" box in a tree definition form.

Remove comments (Without comments this code would disappear from this page)

Edited by: ArtS on Dec 7, 2009 10:45 AM

Edited by: ArtS on Dec 7, 2009 10:45 AM
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 4 2010
Added on May 1 2009
8 comments
3,314 views