Highlight current Tree Node
During the DOAG SIG workshop I was asked how to create a treeview in Oracle APEX where the current selected tree node is highlighted.After a quick thought about the problem, it turned out that there is a quite simple solution for it if you combine the treeview query with some HTML code.
- Create a regular tree region
- Create a form region which gets synchronized with your tree
- Change the tree query to contain the following CASE statement
SELECT EMPLOYEE_ID AS ID
, MANAGER_ID AS PID
, CASE
WHEN EMPLOYEE_ID = :P4_EMPLOYEE_ID THEN
'<span style="color:white;background-color:blue;">'||
LAST_NAME||
'</span>'
ELSE
LAST_NAME
END AS NAME
, 'f?p=&APP_ID.:4:'||:SESSION||'::NO::P4_EMPLOYEE_ID:'||EMPLOYEE_ID AS LINK
, NULL AS A1
, NULL AS A2
FROM #OWNER#.EMPLOYEES
When the tree is rendered the CASE compares the currently processed node (EMPLOYEE_ID) with the current active record (P4_EMPLOYEE_ID) which is displayed in the form.
If the IDs match, it wraps the LAST_NAME column with a SPAN which contains some styling information.
Quite simple, isn't it? :-)
View a working demo of the example.
















5 Comments:
Hallo,
danke für die Hilfe.
Das Ding funktioniert super.
Viele Grüsse
Volker Strasser
By
Anonymous, at 08 June, 2007 15:32
Freut mich!
By
Patrick Wolf, at 08 June, 2007 20:33
Hi Patrick
I'm a big fan of your articles. Very helpful. I'm having strange problem with trees in a sidebar display point. Does anyone have experience where a tree is always blank in a sidebar (or any particular) region? Apex 3.0.1.00.08 - Sand theme.
Thanks
BoeroBoy
By
BoeroBoy, at 23 November, 2007 17:44
Followup: There is a forum on this topic:
http://forums.oracle.com/forums/thread.jspa?messageID=2192202
By
BoeroBoy, at 23 November, 2007 19:59
Hi,
I will do the follow-up on the OTN forum.
Patrick
By
Patrick Wolf, at 23 November, 2007 20:52
Post a Comment
<< Home