cancel
Showing results for 
Search instead for 
Did you mean: 

how to get a index of a table unselectable??u00BFu00BF

anibal_alonso
Explorer
0 Kudos

Hi, I have a problem. In my application I have a table, with the property "selecction Mode = none". In the first column I have a linktoAction where pressing this link, access a new screen that displays the information of the selected node. I tested with the mapping function for the row index of the node that I press, but have received nothing. This is the code used:

...

public static void wdDoModifyView (IPrivateBuscadorEmpleadosView wdThis, IPrivateBuscadorEmpleadosView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean FirstTime)

{

/ / @ @ Begin wdDoModifyView

if (FirstTime) {

....

table.mappingOfOnLeadSelect (). addSourceMapping ("row", "indexRow");

...

}

/ / @ End

}

public void onActionSelecEmpleado (com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, int indexRow)

{

/ / @ @ Begin onActionSelecEmpleado (ServerEvent)

wdContext.nodeEmpleadosOriginal (). moveTo (indexRow)

/ / @ @ End

}

...

How I can fix it? How I can get the index of the column that I have pressed? It is essential that the table has the property "selecction Mode = none", thanks in advance, and sorry for my poor English, greetings.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can achive this by means of Parameter mapping for the link to action UI you are using, below are the steps

1. For the onAction method of the Link to Action UI add an input parameter selectedElement of type IWDNodeElement.

2. Add the below mentioned code in the wdDoModify() method, assuming "la_Link" is the Id of the Link to Action UI added in the table cell


if(firstTime){
     IWDLinkToAction link = (IWDLinkToAction) view.getElement("la_Link");              
     link .mappingOfOnAction().addSourceMapping("nodeElement","selectedElement");
}

3. In the onAction method of the Link to Action UI use the below line of code to get the selected row, using which you can get the corresponding values in that row as well as the row index


IPrivate<ViewName>.I<TableNodeElement> element = (IPrivate<ViewName>.I<TableNodeElement>) selectedElement;
int rowIndex = element.index();

Regards,

Vishweshwara P.K.M.

Former Member
0 Kudos

That specific mapping in the wdDoModify was the one i was missing for the method could properly work.

Thank you Vishweshwara P.K.M .

anibal_alonso
Explorer
0 Kudos

Solved!

Edited by: Anibal Alonso on Mar 9, 2011 6:46 PM

Former Member
0 Kudos

In "newer" releases you can/should define the parameter mapping inside the view designer instead of coding. Right-click the corresponding UI element in the "Outline" view and select the "Parameter Mapping" entry from the context menu. Drag the action parameter from the right side and drop it onto the "nodeElement" event parameter on the left.

anibal_alonso
Explorer
0 Kudos

Thanks Segmentation Fault , I had not noticed that option!

Former Member
0 Kudos

Wow it's true, i hadn't noticed that option either, i just did it that way and doesn't even need to code in the wdDoModifyView.

Thanks a lot!

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

If the table UI property selection mode is set to none then the below mentioned code to fetch the current row value will not work.

wdcontext.currentEmpleadosElement().getAttributename();

So we must use the below code to fetch value

int current_Rowindex = wdcontext.currentEmpleadoselement().index(); 
String value = wdcontext.nodeEmpleados().getElementAt(current_Rowindex).getAttributeAstext("<AttributeName>");

We need to go for parameter mapping to fetch the current row element value only if the table UI property

Compatibility Mode - Nw04plus

By default the compatibility mode is auto.

If compatibility mode is set ot Nw04plus then as Vishweshwara said we need to go for parameter mapping to fetch the current

row value on click of link to action in table column.

Regards,

Bala Baskaran.S

anibal_alonso
Explorer
0 Kudos

Hi, I used the code to my table with the property to none:

int current_RowIndex = wdContext.currentEmpleadosElement().index();

and I can not place it in the row of the table, always choose the first element, ie, element 0

Vishweshwara P.K.M , you were right, I solved the problem with your code, thanks!

Bala Baskaran, thank you very much too

Former Member
0 Kudos

Hi,

You have binded the node Empleados to the table UI element Datasource Property.

You have a linktoaction UI element in one column of the table.

If you have set the selection mode property of table ui to 'none' then the lead selection column will not appear in the

table ui element in output.

Create a event(onAction) for the linktoaction ui element.

In the action write the code to fetch the values:

int current_Rowindex = wdcontext.currentEmpleadoselement().index();

String value = wdcontext.nodeEmpleados().getElementAt(current_Rowindex).getAttribbuteAstext("<AttributeName>");

Read the row attributes one by one using the above code.

Regards,

Bala Baskaran.S

Former Member
0 Kudos

Hi,

If you want to get the selected table row value on click of linktoaction UI

You can use the below code if table ui selection mode = none

int current_Rowindex = wdcontext.currentVnTableelement().index();

//PO_Desc is context attribute Name
String Description = wdcontext.nodeVnTable().getElementAt(current_Rowindex).getAttribbuteAstext("PO_Desc");

Regards,

Bala Baskaran.S

anibal_alonso
Explorer
0 Kudos

Sorry, but I did not understand very well. Do I need to do the mapping?

I haven't a Node "Table" in the context of my view, I have a node of the type of the elements of this table.If I use this method always selects the first node element...

Attached is a picture of the properties of my table

[http://piczasso.com/i/ozspg.JPG]

Former Member
0 Kudos

Hi,

Which version of NWDS are you using?

Regards,

Himanshu

anibal_alonso
Explorer
0 Kudos

SAP NetWeaver 7.1 Composition Environment SP09 PAT0000