cancel
Showing results for 
Search instead for 
Did you mean: 

How to Retrieve Parent node from currently selected node value in Tree UI

Former Member
0 Kudos

Hi All

Currently i am able to retrieve the currently selected node value thru the recursive method as below the code, once i retrieve the currently selected element node value then how to retrieve the immediate parent of the currently selected element.

if any body have the sample code to retrieve the parent node value from currently selected Tree element in a Tree UI element.

The Code i am using currently using to retrieve the currently selected node value from the Tree UI element, but i need sample how to retrieve the parent node value from the currently selected node element, any inputs on the same would be great help to me

public com.sap.tc.webdynpro.progmodel.context.MappedNodeElement getCurrentSelection( com.sap.tc.webdynpro.progmodel.context.MappedNodeElement serviceElement ) {

//@@begin getCurrentSelection()

IPrivateBhq2c_MaintainServiceStrucView.IVn_ServicesOnScreenElement eleChild = null;

if(serviceElement!=null) 
{ 
eleChild = ((IPrivateBhq2c_MaintainServiceStrucView.IVn_ServicesOnScreenElement)serviceElement).nodeChildServicesNode().currentVn_ServicesOnScreenElement();
}

if (eleChild == null)
{
if(serviceElement!=null)
return serviceElement;
else
return null; 
}
else
{
serviceElement = getCurrentSelection (eleChild);
}
if(serviceElement!=null)
return serviceElement;
else
return null;
//@@end
}

Thanks

Kalki reddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

To get the selected tree node (resp. the context element representing it), use IWDNode.getTreeSelection(). To get the parent tree node (resp. the context...) use IWDNode.getParentElement():


IWDNodeElement selection = wdContext.node<TreeDataSource>().getTreeSelection();
IWDNodeElement parentOfSelection = selection.node().getParentElement();

Armin

Answers (0)