cancel
Showing results for 
Search instead for 
Did you mean: 

Go trough a recursive tree

Former Member
0 Kudos

Hi All:

I need to know how can I go trough a recursive tree. I have a tree with various levels, each one with a checkBox associate to it. So, I have to know wick elements from the tree are checked or not.

Any ideas?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

create a recursive function which takes the node as the parameter.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyapparaj:

Can you give ideas about how can get the node´s childs. Which method can I use?.

Thanks

Former Member
0 Kudos

Hi,

Following Link might be of use for you.

http://help.sap.com/saphelp_nw70/helpdata/en/13/4cde139306304480e89d815ffcf891/frameset.htm

Regards

Ayyapparaj

Former Member
0 Kudos

Hi:

I have been trying to get the childNodes from the ROOT, but still I don´t find a suitable method. All the methods I tried gave me a NullPointerException. I just can get the ROOT but not its childs.

Any ideas.

Former Member
0 Kudos

Hi,

If your node structure is as follows

Parent--> Root of the tree

Child -> Recursive node which points to the Parent

Ex:

Iterate through the parent node Elements

for(int x=0; x< wdContext.nodeParent().size(); x++)

{

// get the element

IParentElement nodeElement = wdContext.nodeParent().getParentElementAt(x);

// get the child of the current element

IParentNode node = nodeElement.nodeChild();

}

If the concept is clear, convert the above one to a recursive function.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi

I want to get the information that belongs to each node. How can I do it?

regards.

Former Member
0 Kudos

Please post your exact context structure.

By the way: How did you manage to have a check box at each tree node?

Armin

Former Member
0 Kudos

I was wondering that too xD, not that i need it right now, just it wouldn't hurt to know ;D

Regards.

Julio H

Former Member
0 Kudos

One could simulate a check box with two icons, but that's not really an elegant solution.

Armin

Former Member
0 Kudos

Hi

I have in my context a CatalogEntries node with a recursive ChildNode and some value attributes like a text, isleaf, expanded and ischecked.

I have a TreeByNestingColumn that is bind with the text context attribute and another column with a checkBox that is bind with the ischecked context attribute.

The problem is that I need to go through the tree and check were the element is check or not, but I can´t get it. I tried to do a for of CatalogEntrie node but I just get the first node, the ROOT.

Any ideas how can I solve it?

regards

Aída

Former Member
0 Kudos

Well i made some time ago a routine for dynamic validation of mandatory fields which could navigate within context nodes and check their contents, but it has its limitations since i gotta give all the node names in order to reach certain attribute, maybe you could adapt it to check if it has childs then go deeper into tree, i never tried to navigate to a "parent" node yet, if that can be done then would be easier to achieve what u want.

Maybe it would be easy since its a tree and subnodes names are all the same. Probably making it recursive as Ayyapparaj suggested.

Just my humble opinion...

Regards.

Julio Herrera

Former Member
0 Kudos

CatalogEntries (node, 0:N, singleton=false)
-- ChildNode (rec. node -> CatalogEntries)
-- isChecked (boolean)


void visit(ICatalogEntriesElement entry)
{
  if ( entry.isChecked() )
  {
    /* found checked tree node */
  }
  for (int i = 0; i < entry.nodeChildNode().size(); ++i)
  {
    visit( entry.nodeChildNode().getCatalogEntriesElementAt(i) ); 
  } 
}

visit( wdContext.nodeCatalogEntries().getCatalogEntriesElementAt(0) );

Armin

Former Member
0 Kudos

Hi

How can you change the property singleton to false in the CatalogEntrieNode? I tried to do it, but the IDE don´t let me do it.

Thanks for your help.

Aída

Former Member
0 Kudos

If CatalogEntries is on root level, you don't need to set it.

Armin

Answers (0)