on 12-06-2007 7:05 PM
Hi all,
My table contains a tree structure.
When I select a single row, I need to get the value of a particular column.
I created an action on the leadSelect of the table and gave the following code:
public void onActionleadValue(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionleadValue(ServerEvent)
String strLeadValue = wdContext.nodeAttribute_View_Out().currentAttribute_View_OutElement().getAttributeAsText("<MyModelAttributename>");
wdComponentAPI.getMessageManager().reportSuccess("selected lead value "+strLeadValue);
wdContext.currentContextElement().setLeadselectedvalue(strLeadValue);
//@@end
}
My Bapi returns me 6 records. and when I click on any row its always pointing to the last record value.
What could be the problem?
Thanks
Anjana
It is simple.
Let us assume, Table is your node and name is your value attribute.
Table
- name
wdContext.nodeTable().getLeadSelection(). - is the lead selection.
wdContext.nodeTable().getTableElementAt(wdContext.nodeTable().getLeadSelection()).getName());
Regards,
Sridhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sridhar,
Thanks for your reply.
I am able to get the lead selection values.
But now the problem is I am displaying the values from my bapi in a hierarchy inside my table.
My hierarchy looks like this:
S(Parent) //row 1
---SChild1 //row 2
-
SChild1Leafattribute1 .......attribute2.....attribute3 //row 3
-
SChild2 //row4
-
SChild2Leafattribute1 .......attribute2.....attribute3 //row 5
I am able to get the value of my S(Parent).But not able ti get the value of my SChild1,SChild1Leafattribute1,attribute2 and attribute3.
How can I get these values on my lead select(for eg. on clicking row3)?
Thanks
Anjana.
Hi,
Use treeselection
Ex: wdContext.node<Your Context>().getTreeSelection();
If you want the selected one in any of the actions of the table then you can map the nodeElement
IWDTable tab =//Your table;
Ex:tab.mappingOfOnLeadSelect().addSourceMapping(IWDTreeNodeType.IWDOnLoadChildren.NODE_ELEMENT, "element");
Regards
Ayyapparaj
Hi Anjana,
Try this.
try
{
IWDMessageManager msg = wdComponentAPI.getMessageManager();
int leadselect = wdContext.nodeSChild1().getLeadSelection();
for(int i=0;i<wdContext.nodeSChild1().size();i++)
{
if(leadselect == i)
{
//Displaying output in diff table
// IPublicTestComp.ITableNodeElement tabelm = wdContext.createTableNodeElement();
// tabelm.setAttribute1(wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute1());
// tabelm.setAttribute2(wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute2());
// tabelm.setAttribute3(wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute3());
// wdContext.nodeTableNode().addElement(tabelm);
String att1 = wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute1();
String att2 = wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute2();
String att3 = wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute3();
msg.reportSuccess("Row ("i") : "att1"====="att2"======"+att3);
}
}
} catch (WDDynamicRFCExecuteException e) {
wdComponentAPI.getMessageManager().reportException("Message : "+ e.getMessage(),true);
}
Regards,
Mithu
Hi Ayyapparaj,
I am giving the following code in my wdDoModify method.
IWDTable myTable = (IWDTable)view.getElement("tblfortree");
myTable.mappingOfOnLeadSelect().addSourceMapping(IWDTreeByNestingTableColumn.IWDOnLoadChildren.AttributeViewElemet,"element");
Its giving me error under (IWDTreeByNestingTableColumn.IWDOnLoadChildren.AttributeViewElemet,"element");
I dont have IWDTreeNodeType option. I am using tree by nesting table column for creating my tree structure.
Please guide me how to goahead.
Thanks
Anjana.
Hi
I gave the following code
IWDTable myTable = (IWDTable)view.getElement("tblfortree");
myTable.mappingOfOnLeadSelect().addSourceMapping("row","element");
public void onActionleadValue(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, int element )
{
//@@begin onActionleadValue(ServerEvent)
wdComponentAPI.getMessageManager().reportSuccess("element is "+element);
}
And I am able to get the integer value for each selected row. For eg. if I select the first row, element = 0, if I select row2 element =1 and so on in my tree hierarchy.
Now I want to get the attribute value (column value)in a selected row.
I tried
String strCCode = wdContext.nodeAttributeView().nodeAttributeViewNode(Lead).nodeAttributeViewNode(element-2).getAttributeViewElementAt(element-2).getAttributeAsText("Zcstcd");
Its giving the costomer code value in the third row. But if I click on row 4 its not giving me any value for csutomer code.
How can I get the values?
Thanks
Anjana.
Hi,
Change the following
myTable.mappingOfOnLeadSelect().addSourceMapping(IWDTreeByNestingTableColumn.IWDOnLoadChildren.AttributeViewElemet,"element");
To
<b>myTable.mappingOfOnLeadSelect().addSourceMappingtab.mappingOfOnLeadSelect().addSourceMapping("nodeElement", "element")</b>
<b>element</b> is of type <b>IWDNodeElement</b>
Regards
Ayyapparaj
Hi Ayyapparaj,
If I use your code, its returning me the node((TitleMaintenanceView.AttributeView.0.AttributeViewNode.0.AttributeViewNode.0)
at the selected row.
But my aim is to get the attributes in that row.
Since the tree is getting created dynamically, how can I get the values inside it?
Thanks
Anjana
Hi Ayyapparaj,
I am able to solve the problem by creating the NodeElement as u suggested. Here is how I proceeded.
IAttributeViewElement myElement =(IAttributeViewElement)wdContext.nodeAttributeView().getTreeSelection();
myElement.getEwbez();
wdComponentAPI.getMessageManager().reportSuccess("Tree Selection "+ myElement.getEwbez());
Thanks for you suggestions.
Have awarded points!
Regards
Anjana.
Hi Anjana,
If your table contains a tree structure.
then for getting the correct child selection, you should use :
IWDNodeElement elemnt= wdContext.nodeTable().getTreeSelection();
Regards,
Praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.