当我们在 Controller 中创建 StandardListItems 时遇到问题。我们这样做是因为我们必须调用另一个与 bindItems 相关的 OData 端点来获取附件列表。您可以在下面的详细 Controller 中看到该部分。普通 XML View 中的 press 属性将调用相关 Controller 中的函数。
我们预计以下方法会产生相同的行为。因此,handleItemPress 是处理程序,将在按下项目后调用。
但正如之前所说,没有任何反应。
我们为新闻事件尝试了不同的表示法(有绑定(bind)和没有绑定(bind)):
press: [this.handleItemPress, this]
press: this.handleItemPress
press: "handleItemPress"
但它们都不起作用。那么,我们该怎么做才能使该项目上的新闻发挥作用呢?
详细 View :
<IconTabFilter
icon="sap-icon://attachment"
key="AttachmentTab"
text="{i18n>Attachments}">
<List
id="AttachmentList"
includeItemInSelection="true">
</List>
</IconTabFilter>
详细 Controller :
if (evt.getParameter("key") === "AttachmentTab") {
var template = new sap.m.StandardListItem({
title: "{Objecttext}",
description: "{Filename}",
icon: {
path: "Type",
formatter: sap.ui.prototype.approval.util.Formatter.attachmentIcon
},
press: [this.handleItemPress, this]
});
this._byId("AttachmentList").bindItems(
"/Invoices(Bukrs='" + bukrs + "',Belnr='" + belnr + "',Gjahr='" + gjahr + "',EdcObject='" + edcObject + "')/Attachments",
template
);
}
},
handleItemPress : function (evt){
console.log("The item was pressed");
},
最佳答案
Se StandardListItem 的类型属性。
var 模板 = 新 sap.m.StandardListItem({
类型:“活跃”,
标题:“{Objecttext}”,
描述:“{文件名}”,
关于javascript - 在 Controller 中创建 StandardListItem 并在项目上按下事件不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29227978/