Question

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

Was it helpful?

Solution

If you are binding data try

this.getBindingContext(/*modelName?*/)

or

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

OTHER TIPS

//oControlEvent is the argument from the attachpress event    
     var selectedData = oControlEvent.getParameters().rowBindingContext.getModel().getData();
            var selectedPath = oControlEvent.getParameters().rowBindingContext.getPath();
            var selectedIndex = selectedPath.split("/")[selectedPath.split("/").length - 1];
            selectedData = selectedData[OBJECTNAME][selectedIndex];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top