cancel
Showing results for 
Search instead for 
Did you mean: 

getting currently selected element in tree

Former Member
0 Kudos

hai all,

Iam using tree UI element.

I need to get the currently selected element in the tree.Iam able to get the value in leadselect of table but i need it on the click of the element in tree.

plz help me in this issue.Any help will be greatly appreciated.

Thanks in advance

Sharanya.R

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_bose
Active Contributor
0 Kudos

you can use node->get_lead_selection( ) which returns you element and using get_static_attributes( ) method you can get the values of that element.

If you want ot get the value when you press some link, have an action handler for that link and in the action handler method you can get the current element using wdevent's get_context_element method ( wdevent->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ) which returns element. From element you can get values using get_static_attributes or get_attribute methods.).

regards

nikhil

Former Member
0 Kudos

hai nikhil,

In the onloadchildren action of master column i call a method.

when the user clicks on the parent element of tree i need to get the selected element as that shud be given as input and the subelements shud be obtained.In lead select of table i have already obtained the values .all i need is to get the selected value when user clicks on the arrow next to the parent element in tree.

plz nikhil provide me some solution na.

Thanks n regards

Sharanya.R

Answers (1)

Answers (1)

Former Member
0 Kudos

IWDNode.getTreeSelection()

Armin

Former Member
0 Kudos

hai armin,

There is no such method available under IWDNode.

Please check and let me know the correct code for that.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

use as follows



wdContext.node<YourNode>().getTreeSelection();

Regards

Ayyapparaj

Former Member
0 Kudos

hai ayyapparaj,

i gave

reportsuccess to print the selected element in tree in onloadchildern

the output is

currentNodeElement(Tree_structure_ApplnView.CatalogEntries.0)

I need the text in the tree thats selected.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

Use


 try {
		IWDNodeElement nodeElement = wdContext.nodeOrders().getTreeSelection();
		// Change the line to your own attribute and data type (instead of object)
		Object value = nodeElement.getAttributeValue("<Your Attribute Name>");
		wdComponentAPI.getMessageManager().reportSuccess(value.toString());
	} catch (WDContextException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

Regards

Ayyapparaj

Former Member
0 Kudos

hai ayyaparaj,

i gave the following code in wdmodify method and in the try2 method i tried printing the value.but its not getting printed when i select a value in tree.

try

{

IWDNodeElement nodeElement = wdContext.nodeCatalogEntries().getTreeSelection();

// Change the line to your own attribute and data type (instead of object)

String value = nodeElement.getAttributeAsText(wdContext.nodeCatalogEntries().currentCatalogEntriesElement().getTitle());

wdThis.try2(value);

}

catch(Exception e)

{

e.printStackTrace();

}

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

First, don't add this code inside wdDoModifyView() but to the select action handler.

Second, change it into


try
{
  ICatalogEntriesElement selection = (ICatalogEntriesElement) wdContext.nodeCatalogEntries().getTreeSelection();
  String title = selection.getTitle();
  wdComponentAPI.getMessageManager().reportSuccess("Selected entry: " + title);
}
catch(Exception e)
{
  // should not happen
}

Armin

Former Member
0 Kudos

hai armin,

select action handler?should i create an action handler for that?If so where should i call the action handler?

please guide me doing that.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Just add the code in any event handler or controller method where you want to get the selected node, but not into wdDoModifyView().

Armin