on 02-19-2009 4:55 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
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.
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
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
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
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.
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.