cancel
Showing results for 
Search instead for 
Did you mean: 

How to get selected item from a Smart Table in a Fiori Elements App

Rakesh_Kr
Participant
0 Kudos

Hi Experts,

I was trying to get the selected item/row of the smart table that is displaying the line items in the Fiori Elements App "Manage Sales Contracts" but unable to fetch it. I am basically trying to create a custom List Items app using the OData Service of standard app to fulfill one of my requirement, which is not getting done by normal extensions.

What I am doing: I am trying to get the Selected Context of the table by using below code, but it doesn't work. I picked the table id using the inspect element method.

var oSelectedItem = sap.ui.getCore().byId("com.demo.sap.msc_demo1::sap.suite.ui.generic.template.ListReport.view.ListReport::C_SalesContractWl_F1851--responsiveTable-listUl").getSelectedItems(); 
var item1 = oSelectedItem[0]; 
var cells = item1.getCells();

With above code, i get this error., basically it's not picking table with the id and showing as undefined.

Please suggest.

Thanks,

Rakesh

Rakesh_Kr
Participant
0 Kudos

Hello cain.sun ,

In one of your questions posted here "http://answers.sap.com/questions/606331/question-about-extesionenhancement-on-list-and-obj.html" i see you have figured out this. But when i am trying in my button press logic, it doesn't seem to be working and getting below error "oSource.getParent(...).getParent(...).getTable is not a function".

onButtonPress: function (oEvent) {
  var oSource = oEvent.getSource();
  var oContext = oSource.getParent().getParent().getTable().getSelectedContexts();
  console.log(oContext);
	}

Can you share the piece of code logic you used and suggest.

Thanks,

Rakesh

Accepted Solutions (1)

Accepted Solutions (1)

Rakesh_Kr
Participant

Hi,

Solved using below piece of code:

evt.getSource().getParent().getParent().getSelectedItems();

Thanks,

Rakesh

Answers (0)