cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with getting table element's table row

Former Member
0 Kudos

Hi

My table's first column are buttons.

All buttons in this column are bound to one action.

When the buttons were clicked,I need know which row they belongs to.

Anyone can help me? I'm working with NW7.0

Edited by: steiner fisher on Mar 31, 2009 8:49 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

1.Create a parameter of type IWDNodeElement for your action assigned to your button in the table.

2.Now in your wdDoModifyView write the code given below for Action Parameter Mapping.

IWDButton Button = (IWDButton)

view.getElement("ButtonID");

Button.mappingOfOnAction().addSourceMapping("<nodename>","nodeElement");

Here <node name> is the node which you have bind to the table and "nodeElement" is the parameter name. By writing this code we are dynamically mapping the current node element to the parameter "nodeElement".

3.Now Navigate to the view and select the button from the layout, right click and select parameter mapping.

Now map the nodeElement under the onAction of the button to the newly created parameter for your action.

4.Now in the action of the button write the code to set the lead selection.

public void

onActionActn_searchEmployee(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.sap.wdp.IPrivateContactsView.IVn_salescontacttableElement tableNode )

{

//@@begin onAction <Action name>(ServerEvent)

wdContext.<nodename>.setLeadSelection(tableNode.index());

}

This will help to set your lead selection to the row where your button is pressed. So now

wdContext.<nodename>.getLeadSelection(); will give yoy the index of the row.

Hope this will solve your issue. Please Get back if it is not clear.

Jithin

Former Member
0 Kudos

Thankyou for you reply.

but there's no "add parameter mapping" when i right click the button in layout.

i'm working with NW 7.0

former_member185086
Active Contributor
0 Kudos

No

No, Not in layout ,in outline view where u define the button or other Ui element .

Best Regards

Satish Kumar

Former Member
0 Kudos

The context menu entry should be named "Parameter Mapping". If it is not available in your IDE version, you have to write two lines of code inside wdDoModifyView():


wdDoModifyView(...)
{
  if (firstTime)
  {
    IWDButton button = (IWDButton) view.getElement("id_of_button_used_as_table_cell_editor");
    button.mappingOfOnAction().addSourceMapping
    (
      "nodeElement", /* or better IWDButton.IWDOnAction.NODE_ELEMENT if available in your version)
      "row" /* or whatever the action parameter is named */
    );
  }
}

Armin

Former Member
0 Kudos

No such option there too.

former_member185086
Active Contributor
0 Kudos

Hi

Ok let I Agreed , follow the reply by Armin at wdDoModify Hook method

In either of the way your problem will be solved.

Best Regards

Satish kumar

Former Member
0 Kudos

Hi,

First you write the code which i have already mentioned in wdDomodify.

now in the outline,right click on the button, you will find the option.

Edited by: jithin james on Mar 31, 2009 12:55 PM

Answers (4)

Answers (4)

Former Member
0 Kudos

Add a parameter "row" of type IWDNodeElement (or I<TableDataSourceNode>Element) to your action and action handler.

Use the parameter mapping editor ( Outline view -> Right-Click on button used as table cell editor -> Parameter Mapping).

Drag the action parameter "row" to the predefined event parameter "nodeElement".

In your action handler onAction(..., IWDNodeElement row), the parameter "row" contains the node element to which the button belongs.

Armin

former_member185086
Active Contributor
0 Kudos

Hi

public void onActionSubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.incture.abccomp.wdp.IPrivateTestView.ITestNodeElement element )
  {
    //@@begin onActionSubmit(ServerEvent)
	  wdContext.nodeTestNode().setLeadSelection(element.index());
    //@@end
  }

Here IPrivateTestView.ITestNodeElement element is the parameter of the action (which is bound to table where your button is , Do the parameter mapping right click on button and select parameter mapping )

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi fisher,

When you click button of particular Row.it will automaticaly identified through your lead selection.

int i=wdContext.node<yourtable node name>().getLeadSelection();

if you want to show the record which you had clicked for particular button.

you can use

public void onActionShow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

int i=wdContext.node<your table node name>().getLeadSelection();

wdComponentAPI.getMessageManager().reportSuccess(" particual conlmn"+wdContext.node<your table node name>().get<node name>elememtAt(lead).get<Attribute name>());

;;;;;;;;;;;;;;;;

;;''

Thanks

jati

former_member185086
Active Contributor
0 Kudos

Hi

Create on action with one parameter of type IWDElement of that node which is bound to table .now with this parameter u can do the lead selection or any thing which will specific to selected row.

Best Regards

Satish Kumar