cancel
Showing results for 
Search instead for 
Did you mean: 

Index of ParentNode in Tree Structure

Former Member
0 Kudos

Hi All,

I have Created A Tree UI Element and I need to Display or Use the index of the parent node of the current selected item(element). How To retrieve the value (index) of the Parent Node of the current selected element?

Accepted Solutions (1)

Accepted Solutions (1)

Qualiture
Active Contributor
0 Kudos

Use

int index = element.node().getParentElement().index();

where 'element' is your currently selected child NodeElement

Regards,

Robin

Former Member
0 Kudos

Hi Robin,

I got the index of the parent node , but there is also a requirement to get/ print the name and attributes of the element at that index. simply to put i need to get the parent node name as get text().

Thanks,

Naga.

Qualiture
Active Contributor
0 Kudos

Hi Naga,

The following code will give you the parent node name:

IWDNodeElement parentElement = element.node().getParentElement();
String parentNodeName = parentElement.node().getNodeInfo().getName();

Displaying the parent's attributes can be done in the following way:

Iterator it = parentElement.node().getNodeInfo().iterateAttributes();
while (it.hasNext()) {
	IWDAttributeInfo att = (IWDAttributeInfo)it.next();
	String attName = att.getName();
	Object attValue = parentElement.getAttributeValue(att.getName());
	//do whatever is needed with these attributes
}

Hope this explains

Former Member
0 Kudos

Hi Robin ,

The Problem is Resolved ,Thanks.

Regards,

Naga

Answers (0)