cancel
Showing results for 
Search instead for 
Did you mean: 

Expanding tree node in table by default

Former Member
0 Kudos

Hi ,

In my scenirio i have table which contain tree. And that table i am creating dynamically.in my sceniro i want that tree to be expanded by default.tree node is a master coloumn.ANd it is mapped to isExpanded attribute which is boolean.But if make that is expanded is equal to true it does not expand as i am making a table dynamically. So if anyone have anycode for making tree expanded by default please let me know.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Set the expanded property to true.

Create a context attribute under the Node of type boolean. For all Root node set this attribute value to true

Regards

Ayyapparaj

Former Member
0 Kudos

hi

i already have a context attribute for this of type boolean and i have set it to true but it does not work as table is crated dynamically.so it does not expand by default.

Former Member
0 Kudos

Hi,

Even if table is created dynamic, did you bind this attribute to the TreeByNesting UI element as follows

IWDTreeByNestingTableColumn treeByNestingTableColumn;

IWDAttributeInfo attributeInfo = wdContext.nodeSales_Orders().getNodeInfo().getAttribute("Exp");

treeByNestingTableColumn.bindExpanded(attributeInfo);

Regards

Ayyapparaj

Former Member
0 Kudos

Hi ,

i am not binding the treebynestedcoloumn..

please can you tell me what are steps to do the coding for these.

because what i am doing is simple in the method where are seeting the value in table i am adding

wdcontext.nodeentity.currentenityelement.setisexpanded(true);

where isexpanded is mapped to isexpanded property of treebynestedcoloumn.

Former Member
0 Kudos

Hi,

Can you explain what you are doing?

In the above post you mentioned you are creating the table dynamically.

Are you creating the table or the elements for the node.

It would be help full if you could post what you have done.

Regards

Ayyapparaj

sanyev
Active Participant
0 Kudos

Hi Qutubuddin saifee,

Creating the table UI element dynamically has nothing to do with the nodes being expanded. I believe that you have created the recursive context and loaded the data. If that is the case then you can create a recursive method which will expand the whole tree. Call this method after you have populated the data to the context.

public void expandAll( com.sap.demo.dcbuildtest.test.wdp.IPrivateTestView.IRootNode node )  {
    //@@begin expandAll()
	  for(int i = 0; i < node.size(); i++){
		  IRootElement element = node.getRootElementAt(i);
		  element.setExpanded(true);
		  expandAll(element.nodeChild());
	  }
    //@@end
  }

Here Root is my parent node and Child is my recursive node.

Regards,

Sanyev

Former Member
0 Kudos

Hi ,

for the first time i am calling one method from wdinit().

in this method i am adding the elemnt in table like folloeing

ele1 = node.createENTITYElement();

ele1.setEntity(object.getBusinessUnitDescription());

ele1.setType("Root");

ele1.setStatus(buActFlag);

ele1.setBuId(buUnitId);

/*added by qutub*/ ele1.setShort_Decsription(object.getShort_Description());

ele1.setEditVisible(WDVisibility.VISIBLE);

ele1.setBuVisible(WDVisibility.NONE);

node.addElement(ele1);

after this we are calling addchildren method where we are again adding the children.

sanyev
Active Participant
0 Kudos

Hi Qutubuddin saifee,

As Ayyapparaj mentioned before while Dynamically creating the Table you need to bind the TreeByNestingTableColumn's expanded property to the one in the context.

IWDTreeByNestingTableColumn treeColumn = (IWDTreeByNestingTableColumn)view.createElement(IWDTreeByNestingTableColumn.class, "tree");

IWDAttributeInfo attrib = wdContext.nodeRoot().getNodeInfo().getAttribute("expanded");

treeColumn.bindExpanded(attrib);

Regards,

Sanyev

sanyev
Active Participant
0 Kudos

Hi Qutubuddin saifee,

Is your Hierarchy Table properly working? Is initially nodes not getting fully expanded is your only problem?

Sanyev

Former Member
0 Kudos

Hi ,

my hirachcy table is properly working.. but by default the table is coming unexpanded means only first row is coming...But i want all the level to be expanded by default.Means all hirarchy should be open by default.

Former Member
0 Kudos

Hi,

Ex Context structure

Node

isExpanded --->Boolean

Child --->Recursive of Node

In this which is the attribute that is mapped to the expanded property?

If none of them exist create one lets say isExpanded set this to true in the init

and when ever a root for your tree is created.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi ,

i have attribute ISexpanded and which is mapped to Treebynestingcolumn property expanded. and i made it to true after i am adding element but it does not work..it does not expand.

sanyev
Active Participant
0 Kudos

Hi Qutubuddin saifee ,

In your top level node there should be an attribute of type boolean which stores whether the node is in expanded state or collapsed. Lets say the attribute name is expanded of type boolean.

ele1 = node.createENTITYElement();
ele1.setEntity(object.getBusinessUnitDescription());
ele1.setType("Root");
ele1.setStatus(buActFlag);
ele1.setBuId(buUnitId);
/**added by qutub**/	 ele1.setShort_Decsription(object.getShort_Description());
ele1.setEditVisible(WDVisibility.VISIBLE);
ele1.setBuVisible(WDVisibility.NONE);

ele1.setExpanded(true);

node.addElement(ele1);

Make sure that you bind the expanded attribute to the expanded property of the IWDTreeByNestingTableColumn UI element.

Regards,

Sanyev

Former Member
0 Kudos

Hi

total flow for the logic is like taht..

1. in wdinit we called one method.

2. In this method we create a element and add to table.

3. in wdomodify we write following code

IWDTreeByNestingTableColumn masterColumn =

(IWDTreeByNestingTableColumn) view.getElement("MasterColumn");

masterColumn.mappingOfOnLoadChildren().addSourceMapping(

"path",

"element");

4. On action load childern method we are doing like that

public void onActionLoadChildren(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, entymgmt.wdp.IPrivateEntityMgmtViewOne.IENTITYElement element )

{

//@@begin onActionLoadChildren(ServerEvent)

addChildren(element.nodeENTITYRECURSIVE(), element.getBuId());

//Calling the addChildren() Method

wdContext.currentContextElement().setCurrentParentEntityName(

element.getEntity());

wdContext.currentContextElement().setParentID(element.getBuId());

element.setIsChildrenLoaded(true);

//@@end

}

5. On addchildern method we are doing like this..

IPrivateEntityMgmtViewOne.IENTITYElement el;

el = node.createENTITYElement();

el.setEntity(object.getBusinessUnitDescription());

el.setType(buDescType);

el.setStatus(buActFlag);

el.setBuId(buUnitId);

el.setShort_Decsription(object.getShort_Description());

el.setIsLeaf(true);

el.setBuVisible(WDVisibility.NONE);

el.setOrgVisible(WDVisibility.NONE);

node.addElement(el);

6. Now how to write a code for expansion and which code need to be written.

Former Member
0 Kudos

Hi,

One thing i can see here is that you are IPrivateEntityMgmtViewOne.IENTITYElement el;

2. In this method we create a element and add to table.

add the following line in bold

IPrivateEntityMgmtViewOne.IENTITYElement el;

el = node.createENTITYElement();

el.setIsExpanded(true)

Regards

Ayyapparaj

sanyev
Active Participant
0 Kudos

Hi Qutubuddin saifee,

So from the code it is clear that you are dynamically loading the tree. So when ever the user clicks on the expand icon your loadChildren action handler will be called. This method will load the children for the node the user expanded. That means at runtime all the children are not there in the context. If the tree has to show all the nodes as expanded then all the children has to be loaded to the context.

If you want the whole hierarchy to be expanded initially itself then the approach you are taking is not required. You can load the whole tree initially itself.

After you have loaded the top level nodes to the IENTITYNode you can call the method given below.

public void expandAll( entymgmt.wdp.IPrivateEntityMgmtViewOne.IENTITYNode node )  {
    //@@begin expandAll()
	  for(int i = 0; i < node.size(); i++){
		  IENTITYElement element = node.getENTITYElementAt(i);
		  element.setExpanded(true);
                  onActionLoadChildren(null,element);
		  expandAll(element.nodeENTITYRECURSIVE());
	  }
    //@@end
  }

The code above will expand the whole hierarchy.

Sanyev

Answers (0)