cancel
Showing results for 
Search instead for 
Did you mean: 

Getting index through onSelect action of DropDownByIndex UI element

Former Member
0 Kudos

Does anyone have an example of getting the index of the selected row of a DropDownByIndex UI element

Currently we are always getting a value of zero !? Do you know why ?

We currently use coding like this:

<b>public void onActionSelectGemeente(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, int index )

{

//@@begin onActionSelectGemeente(ServerEvent)

wdContext.nodeGemEtb_Gem_G0().setLeadSelection(index);</b>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

There are two possibilities to get the new selected index:

1. As already said, by asking the node for its lead selection

2. Using event parameter mapping. In this case, you have to add a statement in wdDoModifyView() to map the event parameter "index" of event "onSelect" of the drop-down list to an action event handler parameter.

I would suggest to use case 1. here, it's simpler.

Armin

Former Member
0 Kudos

What statement are you refering at in solution two ?

Former Member
0 Kudos
if (firstTime)
{
  IWDDropDownByIndex dd = (IWDDropDownByIndex)
    view.getElement(<dropdownID>);
  dd.mappingOfOnSelect().addSourceMapping("index", <name of event handler parameter>);
}
Former Member
0 Kudos

Hi,

In wdDoModifyView if u use

<drpdownobject>.mappingOfOnSelect().addSourceMapping("index","argument name in the onSelectfunction say 'sel'")

the index value will be passed to 'sel' as a function argument thorugh the onSelect function and you can get the value using this .

Regards

Bharathwaj

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Heymen,

You can get the index of the selected value from the drop-down list using method getleadselection() from the

wdcontext.node<node name>().getLeadselection();

for using this method you have to set singleton property of this node to false. then and then you can get the index value through this method.

Regards,

Bhavik

Former Member
0 Kudos

Hi,

Since u r creating a argument ur self in the function and not setting it the value is being shoen as zero.

You have to manually use wdContext.node<name>().getLeadSelection() and get it.. Then u can use the value.. and what are u trying to do with setlead selection?

Regards

Bharathwaj

Former Member
0 Kudos

In event handler you have necessary element <b>already selected</b>. So just use wdContext.nodeGemEtb_Gem_G0().getLeadSelection().

VS