the page being created was 76 and this created a page item called P76_TREE_ROOT. For this item, because I am aware of the data, I set the default value to 7839 (the EMPNO for King - the most senior person in the EMP table)
select EMPNO ID, MGR PID, ENAME NAME, NULL LINK, NULL A1, NULL A2 FROM EMP ORDER BY ENAME
EMP is a standard table that comes with an Apex installation. MGR holds the EMPNO for the manager for the employee. Due to the way Tree functionality works, this allows Apex to link from one employee to their manager and so on up to the top most employee (King - EMPNO 7839). The output for the tree is controlled by the template settings on the tree definition - these are created automatically when you select a tree style when creating the tree.
SELECT EMPNO, MGR, ENAME FROM EMP WHERE :P76_EMPNO IN (EMPNO, MGR)
Note that I'm not using the normal LINK field, instead I'm using the A1 field. This was because I wanted to create the link from text other than the ENAME value. If you look at the template settings on the tree definition, at the bottom, you'll see the template used for the LINK - this is wrapped around the #NAME# column (which is my ENAME field). You will also see, in the settings above that, that #A1# is included. #A1# will be replaced by my new link.
select EMPNO ID, MGR PID, ENAME NAME, NULL LINK, '<a class="editlink" href="f?p=&APP_ID.:76:&SESSION.::NO::P76_EMPNO:' || TO_CHAR(EMPNO) || '">(Report)</a>' A1, NULL A2 FROM EMP ORDER BY ENAME
2 - on the page's tree region, I've added the following into the Region Header setting:
select EMPNO ID, MGR PID, ENAME NAME, NULL LINK, '<a class="editlink" href="f?p=&APP_ID.:76:&SESSION.::NO::P76_EMPNO:' || TO_CHAR(EMPNO) || '">(Report)</a>' A1, '<input type="checkbox" value="' || EMPNO || '" name="f01" id="' || NVL(MGR,0) || '" onclick="tickRelated(this)">' A2 FROM EMP ORDER BY ENAME