cancel
Showing results for 
Search instead for 
Did you mean: 

Tree UI Element Selection

Former Member
0 Kudos

Hello all,

I have a requirement wherein for a input field there will a value help which is a customed designed pop up window. In this pop up there will be a tree ui element in which i need that a user can only select the leafs. This means when a user selects a leaf that value should be written in input field.

What is the behaviour of the tree ui element by default. Does it allow selection of a leaf element only by default or do i require custom coding here for my requirement?

Please help.

If you can help me with sample code that would be very beneficial.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks all of you for your inputs

Former Member
0 Kudos

Could you please describe shortly how you solved your issue?

Armin

Former Member
0 Kudos

The steps performed were:

1) Create a Tree Popup window

2) Create a tree element on the view in the window

3) Populate the tree dynamically with MDM data recursively.

4) Keep a boolean attribute hasChildren

5) Set the above attribute when data is leaf/node

6) Use the above attribute on the onAction event of tree

7) Enable Ok button on the view only when data is leaf

😎 Once leaf is selected user pushes OK button and data selected is populated to the main window input field using context mapping.

Regards,

Yogesh Bhatia

Former Member
0 Kudos

You could try this: Bind the "ignoreAction" property of the TreeNodeType to a boolean context attribute inside your recursive context (under data source node). Set the attribute value to false for inner nodes and to true for leaves. Assign an action handler to the TreeNodeType, add an action parameter "treeNode" of type I<DataSourceNode>Element, map event parameter "nodeElement" to action parameter "treeNode".

That should give you a tree where only the leaves are rendered as links and when clicking a leaf, the action parameter will contain the context element representing the leaf.

Armin

Former Member
0 Kudos

Hi Armin,

Thats a brilliant idea! Let me try the same. Let me get back if i face any problems on the same.

Regards,

yogesh bhatia

Former Member
0 Kudos

Hi Armin,

The action handler for the tree node element gives a null pointer exception whenever i try to refer to the treeNode parameter. What can be the reason?

Regards,

Yogesh Bhatia

Former Member
0 Kudos

Hi,

I think you need to do the source mapping for action handler and node element in wdDoModifyView() method.

Regards,

Charan

Former Member
0 Kudos

Hi,

You mentioned that user can only select the leaf node.

What kind of selection do you want to give to user:

1. Table row select - As per my knowledge its not possible to control the table row select like for some of the rows(leafs) it should be selected and for some of the rows(parents) if should not be.

2. Changing the Table Cell Editor Dynamically

3. You can have Button or LinkToAction as UI elements for a particular column and you can enable them only for the rows where isLeaf=true.

Hope this gives you some idea.

Regards,

Charan

Former Member
0 Kudos

Hi Charan,

Thanks for your quick reply. I really appreciate it.

Views on your view points:

Point 1: Table Row Select. Here tree is not embedded within table element. Its independent. Do we need to embed it in table necessarily?

Point 3: Button enablement on isLeaf=true. Is is the isLeaf property available as standard or do we have to make it from a context attribute? How do i make it?

Regards

Former Member
0 Kudos

Hi,

I don't think you need to embed the tree in table.

Hope u have already seen this tutorial, the tutorial mentions abt displaying the selected leaf in the text view.Porbably you can follow the same procedure. Some coding is done wdModifyView for the same

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0ec6622-8da5-2a10-349b-868b6a55...

Former Member
0 Kudos

Hi,

It is not required to embed the table in table. You can implement it at outside the table as well.

Regarding isLeaf property:

Right now how are you identifing your leaf nodes? How will you say this element is leaf and it does not have any more childs?

I think if you had followed the approach in below pdf, then that attribute is "HasChildern" and method is setHasChildren(true);

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

Regards,

Charan

Former Member
0 Kudos

Right now i have not used any property for Children. My tree is being loaded dynamically unlike given in the document has given in which the data is being loaded from a properties file.

Do i need to follow the same approach?

Former Member
0 Kudos

Hi,

No need to follow the approach in document. However you use some attribute or logic or variable to identifiy the nodes which does not have child nodes. Using that attribute or logic or variable chage the UI element enable/disable property also.

Regards,

Charan

Former Member
0 Kudos

public void CreateHierTree( com.sap.mdm.data.HierNode hierNode, com.syngenta.function.wdp.IPrivateFunctionView.IVn_ParentNodeElement parentElement )

{

//@@begin CreateHierTree()

if(hierNode != null && hierNode.getChildren() != null)

{

for(int iChildCount=0 ; iChildCount < hierNode.getChildren().length ; iChildCount++)

{

IPrivateFunctionView.IVn_ParentNodeElement obj = parentElement.nodeVn_ChildNode().createVn_ParentNodeElement();

obj.setVa_Name(hierNode.getChildren()[iChildCount].getDisplayValue().toString());

obj.setVa_RecId(hierNode.getChildren()[iChildCount].getId().id);

parentElement.nodeVn_ChildNode().addElement(obj);

this.CreateHierTree(hierNode.getChildren()[iChildCount],obj);

}

}

//@@end

}

This is my code which am using to populate the tree recursively. can i have an additional isLeaf property and set it to true?

On action of the tree should i check the node elements for the attribute and see its value?

Is it not possible that i keep the node disabled using some property of tree and leafs are automatically enabled?

Edited by: Yogesh Bhatia on Jun 1, 2009 1:40 PM

Former Member
0 Kudos

Hi,

Yes you can have one attribute like "isLeaf"/"HasChildern" to identify a node which does not have anymore childern and you can control the button/linktoaction disable/enable property using this "isLeaf"/"HasChildern" attribute.

Regards,

Charan