cancel
Showing results for 
Search instead for 
Did you mean: 

Code for expanding treenode

Former Member
0 Kudos

Hi @ll,

I have an application that uses the control <htmlb:tree> to display a dynamic tree

structure. In this application I use onClick to select one node in this tree. There

is a group of buttons that allow the user to trigger different actions for the selected

node (i.e. "display details", "add new child node", "expand subtree", ...).

Some of this actions require that I can control the expanding / collapsing of nodes

from within my abap code. Unfortunatelly the "status" property of the treenodes is

only used for initialisation. Modifications to this attribute for already existing nodes

have no effect.

Hope there is a way how to achieve this...

Best regards, Thomas

Accepted Solutions (0)

Answers (2)

Answers (2)

gregorw
Active Contributor
0 Kudos

Hello Thomas,

could you post a code example to give me a easier start testing it.

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

nice to know that I'm not alone out there ;o)

Here is a little code example:

Maybe it's far from my real application,

but I hope it shows the problem...

In HTML "testpage.htm":

  • insert htmlb tree element

<%@extension name="htmlb" prefix="htmlb"%>

<htmlb:tree id = "MY_TREE"

onTreeClick = "entryClick"

table = "<%= mt_tree %>" />

  • mt_tree is of type tview

On Initialzation:

  • insert one node into the tree (root)

DATA l_node type TVIEWNODE.

l_node-treeid = 'MY_TREE'. " id of tree (in html)

l_node-parentid = space. " id of the parent node

l_node-childid = '0001'. " id of this node

l_node-status = CL_HTMLB_TREENODE=>C_TREENODE_CLOSED.

l_node-text = 'click me'. " text of node

CLEAR mt_tree[].

APPEND l_node TO mt_tree.

On Input Processing:

  • react on the event fired by clicking on the node text

  • use this event ('entryClick') to trigger the insertion

  • of a new node as child of the root node

DATA l_node type TVIEWNODE.

l_node-treeid = 'MY_TREE'. " id of tree (in html)

l_node-parentid = '0001'. " id of the parent node

l_node-childid = '0002'. " id of this node

l_node-status = CL_HTMLB_TREENODE=>C_TREENODE_OPEN.

l_node-text = 'child 1'. " text of node

APPEND l_node TO mt_tree.

  • we want that the user can see the newly created child

  • => expand the root node automatically

DATA ls_dummy like line of mt_tree.

ls_dummy-status = CL_HTMLB_TREENODE=>C_TREENODE_OPEN.

MODIFY mt_tree FROM ls_dummy TRANSPORTING status

WHERE childid = '0001'.

>> On startup you will see the tree displaying on single entry named 'click me'. When you click on this entry your code is executed and a new node is added as child of the root node. Moreover the root node should be expanded (which you will realize, doesn't work). That's why you won't see the newly created node.

When expanding the root node manually (by clicking on the little triangle in front of it) you will notice, that the child node is expanded.

As I described, the 'status' attribute is only processed for new nodes. For existing nodes it is ignored. What I need is a way to modify the 'status' attribute for existing nodes...

Best regards, Thomas

Former Member
0 Kudos

I wrote the previous text more than one month ago and got no answer at all. In such a case it is quite difficult to find a solution...

Was my description of the problem so lousy, that nobody understud it? Is it so easy or difficult, that nobody wants to answer? Or has noone even read it?

I don't think that I'm the only guy out there who has this problem. And I would be thankful for EVERY answer!

Best regards, Thomas