0
votes

we have problems when we create StandardListItems in the controller. We do that because we have to call another OData endpoint in relation with bindItems, for a list of attachments. You can see that part below in the Detail Controller. The press property in the normal XML view would call a function in the related controller.

We expected the same behavior with the approach below. Hence that handleItemPress is the handler and will be called after a press on the item.

But as said before nothing happens.

We tried different notations for the press event (with binding this and without):

press: [this.handleItemPress, this]

press: this.handleItemPress

press: "handleItemPress"

None of them worked though. So, what can we do to make the press on the item work?

Detail View:

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

Detail 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");
},
1

1 Answers

1
votes

Se the type property for StandardListItem. var template = new sap.m.StandardListItem({ type: "Active", title: "{Objecttext}", description: "{Filename}",