在控制器中创建StandardListItem并在赢得的项目上按下事件'不要开火

Creating StandardListItem in controller and press event on item won't fire

本文关键字:事件 开火 项目 创建 控制器 StandardListItem      更新时间:2023-09-26

在控制器中创建StandardListItems时遇到问题。我们这样做是因为我们必须为附件列表调用与bindItems相关的另一个OData端点。您可以在下面的详图控制器中看到该部分。普通XML视图中的press属性将调用相关控制器中的函数。

我们在下面的方法中预期了同样的行为。因此,handleItemPress是处理程序,在按下该项后将被调用。

但正如之前所说,什么都没发生。

我们为新闻发布会尝试了不同的符号(有绑定和没有绑定):

press: [this.handleItemPress, this]
press: this.handleItemPress
press: "handleItemPress"

不过,它们都不起作用。那么,我们能做些什么来让媒体对该项目进行报道呢?

详细视图:

<IconTabFilter
    icon="sap-icon://attachment"
    key="AttachmentTab"
    text="{i18n>Attachments}">
    <List
        id="AttachmentList"
        includeItemInSelection="true">
    </List>
</IconTabFilter>

细节控制器:

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 template = new sap.m.StandardListItem({ type: "Active", title: "{Objecttext}", description: "{Filename}",