cancel
Showing results for 
Search instead for 
Did you mean: 

Have some problems by adding children to a tree

Former Member
0 Kudos

Hello everybody,

i am currently trying to build a tree only with to main branches and each branch has one child. Seems not very difficult, but I think I have a basic problem whose solution i cannot find on my own.

I created a value node "eintraege" awith 3 value attributes "spalte1","spalte2","spalte3". The Recursion node is called "Blubb".Now I am trying this:

  IPrivateTreeView.IEintraegeNode node = wdContext.nodeEintraege();
   IPrivateTreeView.IEintraegeElement newElement = node.createEintraegeElement();
   newElement.setMaster("a");
   newElement.setSpalte1("b");
   newElement.setSpalte2("c");
   newElement.setSpalte3("d");
   wdContext.nodeEintraege().addElement(newElement);
   
   IPrivateTreeView.IEintraegeNode nodeChild = node.nodeBlubb();
   IPrivateTreeView.IEintraegeElement newChildElement = nodeChild.createEintraegeElement();
		newChildElement.setMaster("a");
		newChildElement.setSpalte1("b");
		newChildElement.setSpalte2("c");
		newChildElement.setSpalte3("d");
		
		node.nodeBlubb().addElement(newChildElement);

//Now the second entry

	 newElement = node.createEintraegeElement();
	 newElement.setMaster("a2");
	 newElement.setSpalte1("b2");
	 newElement.setSpalte2("c2");
	 newElement.setSpalte3("d2");
	 wdContext.nodeEintraege().addElement(newElement);
   

		  newChildElement = nodeChild.createEintraegeElement();
		  newChildElement.setMaster("a2");
		  newChildElement.setSpalte1("b2");
		  newChildElement.setSpalte2("c2");
		  newChildElement.setSpalte3("d2");
		
		  node.nodeBlubb().addElement(newChildElement);

But i am just able to oben the frist branch and everythink is working fine, I can see the children as well, but when I am trying to open the second branch nothing happens. What I am doing wrong?

Best wishes

Joachim Meyer

Message was edited by:

Joachim Meyer

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Context:


Entries (node, singleton=false)
-- key (attribute, string)
-- Children (recursion node -> Entries)

IEntriesElement a = wdContext.nodeEntries().createAndAddEntriesElement();
a.setKey("a");
IEntriesElement b = wdContext.nodeEntries().createAndAddEntriesElement();
b.setKey("b");

IEntriesElement a1 = a.nodeChildren().createAndAddEntriesElement();
a1.setKey("a1");
IEntriesElement b1 = b.nodeChildren().createAndAddEntriesElement();
b1.setKey("b1");

Armin

0 Kudos

Hi thanks for your reply. My problem is know that I am not able to call the method createAndAddEntriesElement(). ("Method is undefined for the Type IEintraegeElement")

What is going wrong?

Former Member
0 Kudos

Hi,

Call the method on the childnode of the element.

From the above example of Armin

Entries (node, singleton=false)

-- key (attribute, string)

-- Children (recursion node -> Entries)

IEntriesElement a = wdContext.nodeEntries().createAndAddEntriesElement();

a.setKey("a");

IEntriesElement b = wdContext.nodeEntries().createAndAddEntriesElement();

b.setKey("b");

IEntriesElement a1 = a.nodeChildren().createAndAddEntriesElement();

a1.setKey("a1");

IEntriesElement b1 = b.nodeChildren().createAndAddEntriesElement();

b1.setKey("b1");

CreateAnd Add is called on a.nodeChildren().

where a is the element of Entries

nodeChildrens is the recursive node name which in tern points ot the entries.

Regards

Ayyapparaj

Former Member
0 Kudos

createAndAdd...() is a convenience method (introduced in NW 7.0?) that does the same as

I<Node>Element e = node.create<Node>Element();
node.addElement(e);

If not available, use these 2 statements instead.

Armin

0 Kudos

Thank you so much now it's working fine.

Answers (0)