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

Ryan picture Ryan · Mar 24, 2014 · Viewed 15.8k times · Source

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

Answer

Jasper_07 picture Jasper_07 · Mar 24, 2014

If you are binding data try

this.getBindingContext(/*modelName?*/)

or

oEvent.getSource().getBindingContext(/*modelName?*/)