cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the data from selected SAPUI5 table row

Former Member
0 Kudos

Hi,

I would like to read the data from the selected row in SAPUI5 table. I have defined a table in JS view as:

var

sysTable = new DataTable({

     title:

"SAP System List",

     visibleRowCount: 10,

     selectionMode: SelectionMode.Single,

     editable : true

});

The table is binded to JSON data

sysTable.bindRows("/SystemDetails");

I have also used the attachRowSelect function to get the selected row indices.

sysTable.attachRowSelect(function(oEvent){

                  oSystemDetailsML.bindContext(

"/SystemDetails/" + sysTable.getSelectedIndices());  

             });

Lets say the table has two columns as "SysID" and "Description". I am not able to read the data for the selected row.

Tried using the command  alert(sap.ui.getCore().byId("SysID").getValue());   but not sure how this will read the data from selected row.

Thanks,

Yomesh

View Entire Topic
Former Member
0 Kudos

Hi Yomesh,

You have two options for selecting a value from table....

1. You want to get a value for single select

2. You want to get values for multi-select (you will need to use array in this case)

The following code is for single select:

sysTable.attachRowSelect(function(oEvent){

var currentRowContext = oEvent.getParameter("rowContext"); 

var selSysId = oSystemDetailsML.getProperty("SysID", currentRowContext);

var selDesc = oSystemDetailsML.getProperty("Description", currentRowContext);

});

Now if u say var selIndices = oEvent.getParameter("rowIndices"), this will return you an integer array which u can use like this :

selSysId = oSystemDetailsML.oData.SystemDetails[selIndices[0]].SysId;

Regards,

Shubham Agrawal


former_member193103
Participant
0 Kudos

Hi Shubham,

I am trying to show data of a listitem to a popover window. After clicking on the listitem the data will appear on the popover window in some input fields. I am using sap.m library. Can you please show me some example how can I do that?? I have posted a quarry on the same problem..

Thanks

Himadri