相关疑难解决方法(0)

如何在sap.m.table中获取行的内容

所以基本上我的问题是我有一个页面:

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);
});
Run Code Online (Sandbox Code Playgroud)

在这里,我想获得selectedRowContext,我不知道如何?

谢谢

sapui5

6
推荐指数
1
解决办法
2万
查看次数

getBindingContext()返回undefined

我正在开发一个SplitApp.它说,从列表中选择一个项目

未捕获的TypeError:无法读取未定义的属性'getPath'

Master.controller.js

onSelect: function(oEvent) {
  this.showDetail(oEvent.getParameter("listItem") || oEvent.getSource());
},

showDetail: function(oItem) {
  var bReplace = jQuery.device.is.phone ? false : true;
  this.getRouter().navTo("detail", {
    from: "master",
    entity: oItem.getBindingContext().getPath().substr(1),
    tab: this.sTab
  }, bReplace);
}
Run Code Online (Sandbox Code Playgroud)

oItem.getBindingContext()回报undefined.所以我认为问题在于绑定上下文.

Master.view.xml

<List id="list"
  select="onSelect"
  mode="SingleSelect"
  noDataText="{i18n>masterListNoDataText}"
  growing="true"
  growingScrollToLoad="true"
  items="{data>/results}"
>
  <items id="masterList">
    <ObjectListItem id="listItem"
      press="onSelect"
      type="{device>/listItemType}"
      counter="0"
      title="{data>PROJECTNAME}"
      number="{data>REVENUE}"
      numberUnit="{data>CURRENCY}"
      markFavorite="false"
      markFlagged="false"
      showMarkers="true"
    />
  </items>
</List>
Run Code Online (Sandbox Code Playgroud)

Component.js

var oModel= new sap.ui.model.json.JSONModel();
oModel.loadData("Data.json");
this.setModel(oModel,"data");
Run Code Online (Sandbox Code Playgroud)

将显示该列表,但是当我选择该项时,将引发错误.

sapui5

5
推荐指数
2
解决办法
7432
查看次数

标签 统计

sapui5 ×2