2016-04-10 7 views
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); 
     } 
    } 
}); 
}); 

:よう

私のコントローラが見えます。

答えて

0

QuickViewPageをモデル内の特定のエントリにバインドする必要があります。

このため、選択したComboBoxエントリのバインディングパスを取得し、QuickViewPageのバインディングコンテキストとして使用する必要があります。

onPersonnelView: function(oEvent) { 
    var item = this.byId("person").getSelectedItem(); 
    if (!item) { 
     return; 
    } 
    var path = item.getBindingContext("persons").getPath(); 
    this._createPopover("persons>" + path); 

    var oButton = oEvent.getSource(); 
    jQuery.sap.delayedCall(0, this, function() { 
     this._oQuickView.openBy(oButton); 
    }); 
}, 

_createPopover: function(path) { 
    if (!this._oQuickView) { 
     this._oQuickView = sap.ui.xmlfragment("my.app.view.PersonnelQuickView", this); 
     this.getView().addDependent(this._oQuickView); 
    } 
    this._oQuickView.bindElement(path); 
} 
+0

まずはお返事ありがとうございます! getBindingContext()に問題があるようですが、getBindingContext()は返り値を返します。私は何が間違っているのかを見つけようとしているが、私はまだ傾ける。 –

+0

どのようなエラーが表示されますか?項目が選択されていない可能性があります。この場合、getBindingContextは失敗します。この場合、意味をなさないダイアログを開くべきではありません。私はそれに応じて答えを変えた。可能であれば、JS Binを使用してサンプルを作成します。 – matbtt

+0

私はモデル名を与えて、今はgetBindingContextが動作しています。実際に私は別のスレッドにあなたのコメントの1つを見つけました。その名前でアクセスする必要があると言及しました。(あなたのコメントを見つけました。モデルの クイックビューにはまだデータがありません。確かに私の間違いは、QuickViewの要素のバインディングですべきです。 '' –

関連する問題