cancel
Showing results for 
Search instead for 
Did you mean: 

My code to "select" an element in the Tree UI element is not consistently working

Former Member
0 Kudos

Hi,

I created a Web Dynpro component that does many things.  One feature is do display information in a Tree UI element.  I use the TreeNodeType and recursive context node to build a nice tree representing what the customer wants.  Since this tree could get very large, I implemented a search feature to help users locate items in the tree.  When found, I expand the tree, and call call set_lead_selection passing in the element where found.  This seems to generally work fine (and highlights the highlights the desired TreeNodeType), but only when going farther down in the tree. If I change the search so that it should find something "higher up" in the tree, the search still works, and it finds the data, but calling the set_lead_selection does not seem to unhighlight a previously located TreeNodeType.  I have added code to loop through all elements in the tree and call set_selected( ABAP_FALSE).  This didn't seem to help.  If I use the mouse and manually click on the root of the tree, it seems deselect previously highlight TreeNodeTypes, and the highlighting works again (but still just going forward).

I implemented a Find Next feature that starts where the last search left off, and looks farther down the tree.  This works more consistent, but still occassionaly seems to "forget" to unhighlight a previously located TreeNodeType/element.

What am I doing wrong?

I am attaching a screen shot.

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Perry,

Before setting the lead selection of found result, try to clear all the selected elements from context node.

Sample:

               data lo_node type ref to if_wd_context_node.

              

               lo_node = wd_context->get_child_node ( name = 'MY_NODE' ).

              

               "Clear the current selection

               lo_node->clear_selection( ).

               " now, set the lead selection

              

                lo_node->set_lead_selection( .... )

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Thank you Rama for the fast reply.

I had tried calling the clear_selection( ) method from the node of my tree, unfortunately, I could see no improvement.  The only thing that seems to reset the tree is manually clicking on the root of the tree.  Nothing I can find programmatically will properly deselect the previously highlighted tree node (unless the next thing I find is "lower" in the tree).  That is, my search only highlights properly when the next node/element found is lower in the tree.  I always start the search at the root.

It is very frustrating because I believe the users will be using this Search feature a lot.

Answers (0)