cancel
Showing results for 
Search instead for 
Did you mean: 

Sample code for populating the tree hierarchy with Tree UI element

Former Member
0 Kudos

Hi All

I need sample code which is common for creating tree hierarchy structure with Tree UI element for any number of levels when tree increase if user creates many number of child node or parents for example even if they want 50 level hiearchy also.

Currently the code which we written is working only for 5 hierarchy levels in the tree tructure , Please let me know the common code if user dynamically selects at any number of hiearchy levels if they want to create when tree increases.

currently the following code which i am using only for specific hiearchies till 4 levels , if user wants 10 or 20 levels where he creates the tree nodes dynamically then how do we write the common code irrespective of any levels in the tree structure.

selTreeEleInsert=wdContext.nodeVn_ServicesOnScreen().currentVn_ServicesOnScreenElement();
		  if(selTreeEleInsert!=null) ( first level node in Tree)
		  {
		  selTreeEleInsert1= selTreeEleInsert.nodeChildServicesNode().currentVn_ServicesOnScreenElement();
		  }
		  if(selTreeEleInsert1!=null) (second level node in Tree)
		  {
		  selTreeEleInsert2=selTreeEleInsert1.nodeChildServicesNode().currentVn_ServicesOnScreenElement();
		  }
		  
		  if(selTreeEleInsert2!=null) (thirdlevel node in Tree)

		  {
		  selTreeEleInsert3=selTreeEleInsert2.nodeChildServicesNode().currentVn_ServicesOnScreenElement();
		  }
		  
		  if(selTreeEleInsert3!=null) (fourth level node in Tree)
		  {
			  selTreeEleInsert4 = selTreeEleInsert3.nodeChildServicesNode().currentVn_ServicesOnScreenElement();
		  }

Please get back to me with required code with irrespective of any level which user wants to generate any number of levels in a tree dynamically, i need a sample code which works for any number of levels even user needs 10 or 20 levels increase in the tree structure dynamically.

Thanks in Advance

Regards

Kalki reddy

Edited by: KalkiReddy on Jan 6, 2010 5:27 PM

Edited by: KalkiReddy on Jan 7, 2010 5:01 AM

Accepted Solutions (1)

Accepted Solutions (1)

former_member214651
Active Contributor
0 Kudos

Hi Kalki,

Please refer to the document in the below mentioned link for developing a tree structure using the Tree UI element.

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-tech...

Regards,

Poojith MV

Former Member
0 Kudos

Hi,

Please have a look at this document describing the steps to achieve Tree hierarchy.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/47ce9b90-0201-0010-59b5-f70...

Regards,

Saravanan K

Answers (1)

Answers (1)

Former Member
0 Kudos

Say your context structure looks like this


Context
+ Service (node, c=0:n)
   + name (string)
   + Children (recursive node -> Service)

Then you can add a child node at any level to a parent node with


IServiceElement parent = ...;
IServiceElement child = parent.nodeChildren().createAndAddServiceElement();
child.setName("...");

Armin