cancel
Showing results for 
Search instead for 
Did you mean: 

Tree element - opening only one node when selected.

Former Member
0 Kudos

Hi,

We are using a Tree UI element in one of our views, we have created a recursive & reloadable tree.

The tree is being displayed correctly with all the nodes & on clicking the parent node the child is displayed correctly.

Now, can somebody please tell me how to close a node that was opened previously when another node is clicked.

Say for ex:

If my tree has got parent nodes as Cricket, Soccer, & Tennis, each with their child nodes respectively,

Now that If I click Cricket then it's child node is displayed correctly , but then If I click the parent node named Soccer , though the child nodes of Soccer are correctly displayed in the tree, I want to know that when I click Soccer , the previously opened parent nodes should be closed.

i.e Only one parent node when selected should be open & all other parent nodes in the tree should be closed.

Can somebody please help me with this problem. Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

saikrishna,

This sounds for me same like this:

Please read my reply to this thread:

Sadly, author does not reply whether it was the solution he were loking for. However, in my NW04s environment it works like expected.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi Valery,

Thanks a lot for your help. The problem has been solved & the tree is working fine. It will be very nice if you give the therotical explaination of the code you had written for shrinking.

thanks,

Saikrishna

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Store the reference of the openend node in a conttext variable. On click to open next node, set the isExpanded property of the previous node as false with the help of the context variable which has the reference of the previous node.

Former Member
0 Kudos

Hi,

I have set the reference of the open node in a context variable as u said and Is expanded property as well. I have given the code here, please correct where i am going wrong.

public void addChildren( com.cpt.tree.sen.wdp.IPrivateTreeSenView.IFolderContentElement parent )

{

...

wdContext.currentContextElement().setElementExpanded(parent.index());

}

public void onActionLoadChildren(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.cpt.tree.sen.wdp.IPrivateTreeSenView.IFolderContentElement element )

{

IPrivateTreeSenView.IFolderContentNode folderContentNode =publicFolderContentNode;

if(wdContext.currentContextElement().getElementExpanded() != -1) {

IPrivateTreeSenView.IFolderContentElement nodeElement= folderContentNode.getFolderContentElementAt(wdContext.currentContextElement().getElementExpanded());

nodeElement.setIsExpanded(false);

}

}

IPrivateTreeSenView.IFolderContentNode publicFolderContentNode = null;

Thanks,

Regards,

Senthil Kumar S.