cancel
Showing results for 
Search instead for 
Did you mean: 

Search perticular element in a tree

arjun_thakur
Active Contributor
0 Kudos

Hi Experts,

I have a requirement in my proj in which I have to search a perticular element in the tree.

I have created a tree structure and there is an input field on the screen as well. Now when I enter any value in the input field and clink on search button, that value (if present in the tree) should get lead selected. If the node is not expanded and a value is searched, the tree should expand and that value should be highlighted. Can we achieve this functionality?? If yes, then please guide me.

Thanks

Arjun

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Arjun,

You could always do it.

Once you get the text in the input field, you could read the context which is maintained for the tree node which would maintain the text, parent id, state etc, so the tree node state(expanded/collapsed) is also maintained as a boolean value whether it is expanded or not, which you can fill explicitly. so you just have to fill the context data correctly. and once done, you could explicitly set the focus on the node as well.

Regards

Anurag Chopra

arjun_thakur
Active Contributor
0 Kudos

Hi Anurag,

Thanks for your reply.

In the ONACTIONLOADCHILD method of the tree I use the following code to get the ref of the node that has been expanded.

data: lr_element type ref to if_wd_context_element.
lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ). 

But if I click on serach button, how would I get the ref of node which should be expanded?

Regards

Arjun

Former Member
0 Kudos

Hi Arjun,

if i have understood your requirement clearly. You need to fill the context for the tree by supply function,

Former Member
0 Kudos

Hi Arjun,

You need to fill the context node by the supply function if you expect one to search the the tree by the input field as one can select the tree's element at any level.

So as soon one enters the text (tree element which could be a node or a children ), you need to search the internal table and identify at what level the element belongs to and then you just need to change the boolean value of the expand property.

You can get the reference of the node by first accessing the root node and then for the tree node by passing the name of the node.

Regards

Anurag Chopra

Edited by: Anurag Chopra on Dec 23, 2009 7:21 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can refer this link -

Here the element of treee is default selected..

based on your requriement you can achive the same using this link -

Regards,

Lekha.