在UI5中的UploadCollectionItem中设置URL 1.38.4

时间:2016-09-09 00:16:38

标签: sapui5

对于设置了URL参数的UploadCollectionItem,必须使用哪些参数将在单击文件名时显示该文件。

我正在使用工厂来处理来自不同位置的文件。

attachmentFactory(sId, context) {
  const modelObj = context.getModel().getProperty(context.getPath());
  const uploadListItem = new SAPUploadCollectionItem();

  // If __metadata exists, attachment entry is from odata, if not then it's a FileEntry object.
  if (modelObj.__metadata) {
    uploadListItem.setFileName(modelObj.FILE_NAME);
    uploadListItem.setMimeType(modelObj.MIME_CODE);
    uploadListItem.setUrl("https://upload.wikimedia.org/wikipedia/commons/4/49/Koala_climbing_tree.jpg");
  }
  else {
    uploadListItem.setFileName(modelObj.name);
    uploadListItem.setMimeType(modelObj.type);
    uploadListItem.setUrl("https://upload.wikimedia.org/wikipedia/commons/4/49/Koala_climbing_tree.jpg");
  }
  return uploadListItem;
}

当我按下函数

中的链接时,我在UI5中遇到异常
UploadCollection.prototype._triggerLink = function(oEvent, oContext) {
    var iLine = null;
    var aId;

    if (oContext.editModeItem) {
        //In case there is a list item in edit mode, the edit mode has to be finished first.
        sap.m.UploadCollection.prototype._handleOk(oEvent, oContext, oContext.editModeItem, true);
        if (oContext.sErrorState === "Error") {
            //If there is an error, the link of the list item must not be triggered.
            return this;
        }
        oContext.sFocusId = oEvent.getParameter("id");
    }
    aId = oEvent.oSource.getId().split("-");
    iLine = aId[aId.length - 2];
    sap.m.URLHelper.redirect(oContext.aItems[iLine].getProperty("url"), true);
};

oContext.aItems是一个数组,但source.getId()值是" __ item9-ta_filenameHL"所以在oContext.aItems

中找不到__item9

我不确定这是不是错误,或者我没有错误地设置我的UploadCollectionItem

1 个答案:

答案 0 :(得分:1)

我必须将UploadCollectionItem的sId设置为传递给工厂的sId。