cancel
Showing results for 
Search instead for 
Did you mean: 

How to highlight/indicate particular tree Node in Tree UI element

Former Member
0 Kudos

Hi All

Can anybody let us know how to highlight/indicate specific node in a tree struture.

currently i am able to display the tree struture with all the nodes & elements but it is always tasking firstnode as highlighted one or indicated one.

if i want to highlight specific node in a tree struture...what was the procedure or any sample code then it would be great help to us.

Thanks

Trisha rani

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Just set the tree selection in the context to the node element that represents the tree node:


wdContext.node<TreeDataSource>().setTreeSelection(nodeElement);

Armin

Former Member
0 Kudos

Hi Armin

The sample code which you provided for highlighting is working for parent nodes, it wwas not working for child nodes.

for example

A
  A1	
    A2
    A3
    A4	

B 
  B1
    B2
    B3
    B4	

As per your code i am able to hight the nodes of A,A1,B,B1 but i am not able to highlioght the child nodes like B1,B2,B33,B4 etc.

your code is working only for parent nodes not for child nodes.

Can you pls provide sample code to make highlight the child nodes?? then it would be great help to me

Thanks

Trisha Rani

Former Member
0 Kudos

Hi,

Change this code as below and try:


public void searchAndHilightNodeElement( com.sap.tut.wd.treetable.wdp.IPrivateTreeTableView.ICatalogEntriesNode node, String searchItem )
  {
    //@@begin expandAll()
    
    for (int i = 0; i < node.size(); i++) {
 
    if(searchItem.equalsIgnoreCase(node.getCatalogEntriesElementAt(i).getPARENTID()))
     {
           //Here we need to set for main tree node - this is the change	          
           wdContext.nodeCatalogEntries().setTreeSelection(node.getCatalogEntriesElementAt(i));
     }
    else if(node.getCatalogEntriesElementAt(i).getIsLeaf()==false)
     {
      //We need to expand the parent nodes until we find the child node to be selected 
      node.getCatalogEntriesElementAt(i).setExpanded(true);
      searchAndHilightNodeElement(node.getCatalogEntriesElementAt(i).nodeChildCatalogEntries
      (),searchItem);
     }
}

Note: Before you call this method all the child nodes should be populated in the init method.

Regards,

Charan

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Can you pls explain what do you mean of hilighting tree node?

You mean to say table row select Or node expand?

Regards,

Charan

Former Member
0 Kudos

Hi Krishna

Thanks for your reply

I displayed the tree structure and i want to highlight specific parent node/child element , what was the sample code??

for example my tree was displayed in the below struture and at the runtime specific child node i wanted to be highlighted i want to make selectable particular nodeType......

Can you pls send sample codee code??

my requirement

A
 A1
   A2
   A3
B
 B1 	
   B2
   B3
   B4
   B5	

now i want to make selectable or highlighted B4,B5 etc or A2,A3 at runtime.

The other guy who replied for this thread it is working for Parent nodes to make highlighted like it is working for parent nodes which is have child nodes. i am able to hightlight at runtime for Nodes A,B etc .

Now i want to highlight or make selected one for B4,A3 etc, pls provide sample code??

it would be great help to us

Thanks

Trisha Rani

Former Member
0 Kudos

Hi,

You need to check all the child nodes also recursively.

for example write a method as below.


public void searchAndHilightNodeElement( com.sap.tut.wd.treetable.wdp.IPrivateTreeTableView.ICatalogEntriesNode node, String searchItem )
  {
    //@@begin expandAll()
    
    for (int i = 0; i < node.size(); i++) {

    if(searchItem.equalsIgnoreCase(node.getCatalogEntriesElementAt(i).getPARENTID()))
     {
	node.setTreeSelection(node.getCatalogEntriesElementAt(i));
     }
    else if(node.getCatalogEntriesElementAt(i).getIsLeaf()==false)
     {
      searchAndHilightNodeElement(node.getCatalogEntriesElementAt(i).nodeChildCatalogEntries(),searchItem);
     }
}

And invoke this method whenever you want to hilight a particular node as below:

searchAndHilightNodeElement(wdContext.nodeCatalogEntries(),"B4");

I did not test this code. Please revert back if you face any issues.

Regards,

Charan

Former Member
0 Kudos

Hi Krishna

It was not working fine.

i am getting the following error while trying to higlight the child nodes at runtime

com.sap.tc.webdynpro.progmodel.context.ContextException: Node(com_tasks_stats_Comp/com_tasks_stats_CompView.TreeNode.1.Child, class=com.sap.demo.com_tasks_status.com_tasks_stats_comp.wdp.IPrivatecom_tasks_stats_CompView$ITreeNodeNode): NodeElement(.com_tasks_stats_CompView.TreeNode.Child) is not in node's subtree

Can you pls help me out what was the simple way or method to make highlight the child nodes for example B4,A4 etc.

Thanks

Trisha rani