我尝试使用片段内的UploadCollection从oData服务上传Fiori应用程序的附件。
片段代码:
<core:FragmentDefinition xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form" xmlns:core="sap.ui.core" xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<UploadCollection id="UploadCollection" maximumFilenameLength="55" multiple="true" change="onChange" fileDeleted="onFileDeleted"
fileRenamed="onFileRenamed" fileSizeExceed="onFileSizeExceed" items="{/DataAttachment}" typeMissmatch="onTypeMissmatch"
uploadComplete="onUploadComplete">
<items>
<UploadCollectionItem contributor="{contributor}" documentId="{documentId}" fileName="{fileName}" fileSize="{fileSize}"
mimeType="{mimeType}" thumbnailUrl="{thumbnailUrl}" uploadedDate="{uploadedDate}" enableEdit="{enableEdit}" enableDelete="{enableDelete}"/>
</items>
</UploadCollection>
</core:FragmentDefinition>
详细代码:
<IconTabFilter icon="sap-icon://attachment" iconColor="Neutral" design="Horizontal" text="Attachment" key="Attachment">
<content>
<core:Fragment id="AttachmentFrag" fragmentName="ztravel.view.Attachment" type="XML"/>
</content>
</IconTabFilter>
控制器详细信息代码:
var sEntityPath = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSERVICE/", true);
// this.setModel(oViewModel);
// this.getView().bindElement("/DataAttachment");
var oView = this.getView();
// oView.bindElement(sEntityPath);
// update list binding
var sAttach = sEntityPath + "/DataAttachment";
var oItemTemplate = new sap.m.UploadCollectionItem({
documentId: "{Pernr}",
fileName: "{Reinr}",
mimeType: "{ImMimeType}",
thumbnailUrl: "",
// url: {
// parts: [{
// path: 'ImImgEqui'
// }, {
// path: 'ImIdEqui'
// }],
// formatter: function(idimg, idequi) {
// return oView.getModel().sServiceUrl + "/AttachmentsSet(ImImgEqui='" + idimg + "',ImIdEqui='" + idequi + "')/$value";
// }
// },
enableEdit: false,
enableDelete: false,
visibleDelete: false,
visibleEdit: false,
statuses: new sap.m.ObjectStatus({
title: "Uploaded On",
text: {
parts: [{
path: 'ImDatum'
}],
formatter: function(sValue) {
if (sValue) {
var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({
pattern: "dd/MM/yyyy"
});
return oDateFormat.format(new Date(sValue));
} else {
return sValue;
}
}
}
})
});
// var fragmentId = this.getView().createId("AttachmentFrag");
// var tab = sap.ui.core.Fragment.byId(fragmentId, "UploadCollection");
// tab.bindItems({
// path: sAttach,
// template: oItemTemplate
//});
sap.ui.core.Fragment.byId("AttachmentFrag", "UploadCollection").bindItems({
path: sAttach,
template: oItemTemplate
});
控制台给我这个错误: TypeError:无法读取未定义的属性“bindItems”
关于详细控制器代码的最后部分: sap.ui.core.Fragment.byId(“AttachmentFrag”,“UploadCollection”)。bindItems({....
你可以帮我解决这个问题吗? 谢谢大家,微型飞行器
答案 0 :(得分:0)
试试这个:
sap.ui.core.Fragment.byId(this.getView().createId("AttachmentFrag"), "UploadCollection")