0
我在XML視圖中有一個組合框和一個單獨的按鈕。按下事件按鈕調用QuickView控件。 問題是我無法從組合框的選定綁定路徑填充QuickView的數據。SAPUI5綁定從組合框控件到快速瀏覽的彈出窗口
組合框的項目位於json文件中。
<ComboBox id="person" showSecondaryValues="true"
items="{persons>/Persons}">
<items>
<core:Item key="{persons>ID}" text="{persons>Name}"/>
</items>
</ComboBox>
<Button icon="sap-icon://personnel-view" press="onPersonnelView"/>
是在清單中聲明JSON文件是:
{
"Persons": [
{
"ID": "id01",
"Name": "name",
"Roles": "role",
"Mobile": "555",
"Phone": "555",
"Email": "[email protected]",
"Address": "address 99",
"CompanyID": "cid01"
}]}
和清單部分:
"models": {
"persons": {
"type": "sap.ui.model.json.JSONModel",
"uri": "TestData/persons.json"
}
組合框就像一個魅力,並與「人」的結合模型似乎很好。
我的控制器看起來像:
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("my.app.controller.Form", {
onPersonnelView: function(oEvent) {
this._openQuickView(oEvent);
},
_openQuickView: function(oEvent) {
this._createPopover();
var oButton = oEvent.getSource();
jQuery.sap.delayedCall(0, this, function() {
this._oQuickView.openBy(oButton);
});
},
_createPopover: function() {
if (!this._oQuickView) {
this._oQuickView = sap.ui.xmlfragment("my.app.view.PersonnelQuickView", this);
this.getView().addDependent(this._oQuickView);
}
}
});
});
快速視圖顯示本身,而是它是空的。
首先感謝您的回答! 我的問題似乎是「getBindingContext()」,因爲我得到和未定義的返回。我試圖找出我做錯了什麼,但我仍然不能。 –
你會得到什麼錯誤?可能沒有選擇任何項目。在這種情況下getBindingContext失敗。在這種情況下,你不應該打開一個對話框,因爲它沒有意義。我相應地改變了答案。如果可能的話,使用JS Bin創建一個示例。 – matbtt
我給出了模型名稱,現在getBindingContext正在工作。 'var bindingPath = this.byId(「responsible」)。getSelectedItem()。getBindingContext(「persons」)。getPath();' 其實我發現你的一條評論給另一個線程,提到需要用名字訪問的模型。 仍然QuickView錯過了數據。當然,我的錯誤現在應該通過QuickView的元素綁定。 例如' Mobile}」type =「mobile」/>' –