Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get content of a row in sap.m.table

Tags:

sapui5

So basically My problem is I have a page:

var page1 = new sap.m.Page({
title: "Something", 
enableScrolling : true, 
content : [
    oTable = new sap.m.Table("items", {
        columns : [
            new sap.m.Column({
                styleClass : "name",
                hAlign : "Left",
                header : new sap.m.Label({
                    text : "firstColumn"
                })
            })
        ]
    })]
});
var template = new sap.m.ColumnListItem({
    type : "Navigation",
    cells : [
        new sap.m.Label({
            text : "{name}"
        })
    ]
});
template.attachPress(function(oEvent){
    var selectedRowContext = oEvent.getParameter("item");
    alert(selectedRowContext);
});

Here I want to get the selectedRowContext and I don't know how?

Thank you

like image 347
Ryan Avatar asked Mar 24 '14 00:03

Ryan


People also ask

How do I find data in SAP M table?

You can get all the Items in the table using getItems(), which will give you an Array of Items. You can then get the bindingContext for any of the Items.

How to get selected row in sap ui table?

Method- getSelectedIndices() will return array of selected Indexes. Then you can use the method: oTable. getContextByIndex(index_number). getObject() : to fetch the selected context object.


1 Answers

If you are binding data try

this.getBindingContext(/*modelName?*/)

or

oEvent.getSource().getBindingContext(/*modelName?*/)
like image 144
Jasper_07 Avatar answered Jan 02 '23 22:01

Jasper_07