0
讓我們想象一下,我們有sap.m.UploadCollection
,我們將數據綁定到這個集合這是這樣完成的:如何在工廠方法中獲得另一個上下文路徑?
bind: function() {
this._oUploadCollection.bindAggregation("items", {
path: "/attachments",
factory: jQuery.proxy(this._bindUploadCollectionItem, this)
});
},
綁定數據的例子是在這裏:
{
"attachments": [
{
"size": 123,
"filename": "pdf.pdf",
"id": "pdfId"
},
{
"size": 440,
"filename": "text.txt",
"id": "textId"
}
],
"source":"personWhoAddedAttachments"
}
所以,在_bindUploadCollectionItem
我成功可以得到size
,filename
和id
通過oContext.getProperty("nameOfParameter")
,但不能得到source
:
_bindUploadCollectionItem: function (sID, oContext) {
return new sap.m.UploadCollectionItem({
"id": oContext.getProperty("id"),
"fileName": oContext.getProperty("filename"),
"attributes": [
{
"title": "author",
"text": oContext.getProperty("../source") // <- problem
}]
});
},
所以,因爲我綁定了attachments
這很明顯,我無法獲得source
,但如何在需要時達到它?
感謝,oContext.getModel()。getProperty(「/ source」)使它工作! – Rufi