cancel
Showing results for 
Search instead for 
Did you mean: 

Get selected Item from SAPUI5 List

Former Member
0 Kudos

In my view.js, I have my list defined:

var oList = new sap.m.List({

    

growing: true,

growingThreshold: 10

    

});

Looking for a simple example of getting the selected value from the list.  Can anyone provide code snippet or idea on how to accomplish this?  Thanks.

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member557605
Participant
0 Kudos

Hi

You can find here sumple and useful .

Regards,

Rupesh

Former Member
0 Kudos

Hi,

Please use the below code to get the selected item from list

var oList = this.byId("productsList"),

  oBinding = oList.getBinding("items");

  var items = oList.getSelectedItems();

  for (var i = 0; i < items.length; i++) {

   var item = items[i];

   var context = item.getBindingContext();

   var obj = context.getProperty(null, context);

   alert(obj.Name);

  }

Thanks & Regards,

Hemachandran.R

0 Kudos

var table = this.getView().byId("tableId");

var rowItems = table.getSelectedItems();

var asnnum = rowItems[0].mAggregations.cells[1].getProperty("text");

To achive the above please use selectionChange="your function name" property in your table and hadel the above inside your function

former_member182862
Active Contributor
0 Kudos

Hi Jay

Here is an example.

-D

0 Kudos

Did you try with the command

var selItems = view.oList.getSelectedItems();

Regards,

Simmaco