cancel
Showing results for 
Search instead for 
Did you mean: 

How to iterate through a Recursive context node in WebDynpro

Former Member
0 Kudos

Hi all,

I have a Application in which the i'm using a Tree structure for a table.

the table is being populated using a recursive context.

I need to know how to iterate through recursive context nodes.

Thanks in advance

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

How can i get the immediate parent node of the child element.

nikhil_bose
Active Contributor
0 Kudos

INodeElement child_element;

child_element.node().getParentElement();

Former Member
0 Kudos

Hi,

use

element.node();

Regards

Ayyapparaj

PradeepBondla
Active Contributor
0 Kudos

Hi,

Here is the code example for recursive node in tree UI element

http://help.sap.com/saphelp_nw04/helpdata/en/16/1ec1814e566f4baf943c53ccf48552/content.htm

from http://help.sap.com/saphelp_nw04/helpdata/en/c2/abfceffbacd24185ec7af8a3a2e76a/content.htm

here you have step by step with screen shots

Pradeep

Former Member
0 Kudos
Former Member
0 Kudos

Example:


Entries (node, 0:n)
-- id (string)
-- SubEntries (recursive node -> Entries)

void visit(IEntriesElement entry)
{
  /* do something with entry... */

  /* visit sub-entries */
  for (int i = 0, n = entry.nodeSubEntries().size(); i < n; ++i)
  {
    IEntriesElement subEntry = entry.nodeSubEntries().getEntriesElementAt(i);
    visit(subEntry);
  }
 
}

Armin

Former Member
0 Kudos

Hi Armin,

Your code was very help full in iterating through the recursive context.

I have one more question.

When i select different rows of the table (a table with master column, My idea is to provide a tree like structure to the table), how to jump to that particular child node (upon lead selection of the table that is)

What i have noticed is, when we are using Master Column for a table, the Action onLoadChildren is executed only once.

every time i expand a random row of the table i want the child node its referencing.

please help

Regards,

Shibin

Former Member
0 Kudos

I don't understand your question completely. Do you want to set the tree selection to the context element (tree node) that has just been loaded?

Armin

Former Member
0 Kudos

Hi Armin,

Thats exactly what i want to do.

Former Member
0 Kudos

Use event parameter mapping to get the context node element that represents the expanded/loaded tree node:

Either (if IDE allows it) by using the parameter mapping editor or by code like the following inside wdDoModifyView():


 if (firstTime)
 {
   IWDTreeNodeType myTreeNodeType = (IWDTreeNodeType) view.getElement("ID-of-TreeNodeType");
   myTreeNodeType.mappingOfOnLoadChildren().addSourceMapping
   (
     IWDTreeNodeType.IWDOnLoadChildren.NODE_ELEMENT, // event parameter name
     "treeNode" 
   ); 
 }

Then the action parameter named "treeNode" (type IWDNodeElement or typed version) will contain the context node element representing the tree node for which the children just have been loaded.

To set the tree selection to this element, use code like this in the action handler:


try
{
   wdContext.node<TreeDataSource>().setTreeSelection(treeNode);
}
catch (ContextException)
{
  /* should not happen */
}

Armin

Former Member
0 Kudos

Hi Armin,

Thank yop for your response.

I'm using IWDTreeByNestTingTableColumn

as I'm using a MasterColumn along witha Table UI element.


    if(firstTime)
    {
        IWDTreeByNestingTableColumn masterColumn =
                     (IWDTreeByNestingTableColumn)   view.getElement("MasterColumn1");
            masterColumn.mappingOfOnLoadChildren().addSourceMapping("path", "element");
   }
 

Every time i expand a node , the children will be added by event handler method for onLoadChildren.

When i contract the node, is there a way to un-load the children?

for Example:

Context

|----->Skill(Value node)

&nbsp; &nbsp; &nbsp; |------->ChildSkill(Recursive node under Skill)

ROOT

|------->

| &nbsp; ITS

| &nbsp; &nbsp; &nbsp; |----


>JAVA

| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |----


>OOPS

| &nbsp; &nbsp; &nbsp; |----


> .Net

|

|----


>

| &nbsp; RDS

| &nbsp; &nbsp; &nbsp; |----


>Skills

| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |----


>Reading

| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; |----


>Writing

|----


>

&nbsp; CORP

now when i click on ITS its children will be loaded as event handler for onLoadChildren will be executed along with "element"(as declared in wdDoModifyView() ) as one of the params.

Later when i Click on RDS and again if I come back to ITS how do i point to the corresponding Skillnode in my context.

Former Member
0 Kudos

Hi,

Just go through the following link. This will help you to achieve your requirement.

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

thanks & regards,

Manoj

nikhil_bose
Active Contributor
0 Kudos

you can get the parent from

IWDNodeElement el;

el.node().getParentElement();

plz refer [thread: retrieve path of tree|]

nikhil