Skip to Content

SAP UI5 how select a table row and get data?

Oct 24, 2016 at 02:46 PM


avatar image
Former Member


I made this table and would like to get information from selected row. How can I select row and get information?

And how can I improve table style?

Thank you in advance!

unbenannt.png (70.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Sai Vellanki Oct 25, 2016 at 12:11 AM

Hi Khristina,

Will this sample help? Table

Regarding the table style, what do you like to do? You want to add some border-design / colors etc?



10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 26, 2016 at 10:55 AM

Thank you for your answers. But unfortunately it's not working.

var rowid = tb.getSelectedIndices(); The programm says that getSelectedIndices() is not defined. Could you please me also say how can I set a value? I would like to get something like this when I choose a row.

Status: Anzahl Anteil%

Offen 6 66%

I wrote like this and it works...but I don't know how to set a value

    onSelectionChange: function(oEvent) {
            var oSelectedItem = oEvent.getParameter("listItem");
            var s1pt = oSelectedItem.getBindingContext().getProperty("Status02Perc");

unbenannt.png (13.3 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

If you want to set a value to a cell, you need to set it to the bound model. (Not to the table cell directly)

avatar image
Former Member Oct 25, 2016 at 01:11 AM


You can use the following function to get the selected row, then get the value from a specific column:

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

var rowid = tb.getSelectedIndices();

var kosten = tb.getRows()[rowid].getCells()[0].getText();

var object = tb.getRows()[rowid].getCells()[1].getText();



10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 02, 2016 at 11:42 PM

I am not sure what you try to do ... but I am exptecting the following

you have a table with information. You click on a line and you want to see that information displayed now in a form for example. Only that one line information you have selected in the table before. and you used sap.m.table for the table

Therefore you can reach this with the following .. by using a Dialog Fragment to display the detail information and bind the context of the selected line to the context of the form in the dialog fragment

in your controller

closeDialog: function()

{ this._getDialog().close(); this._oDialog.destroy(); this._oDialog = false;


onExit: function()

{ if (this._oDialog) { this._oDialog.destroy(); }


onSelectionChange: function(oEvent){



_getDialog: function(){

//check if dialog is not open at all

if (!this._oDialog) {

var oTable = this.byId("yourTableId");

this._oDialog = sap.ui.xmlfragment("namespace.fragmentName", this.getView().getController());


var sSelectedContext = this.getSelectedContexts().toString()

//binding fragment form to SelecteContext of Table



return this._oDialog;


10 |10000 characters needed characters left characters exceeded