2017-05-04 3 views
-1

タイルメニューをバインドしたいが、バインディング選択に問題がある。データバインディングJSON SAPUI5(タイルメニュー)

{ 
     "module":{ 
      "module":[ 
       { 
        "id": "0", 
        "name": "Kepesertaan" 
       }, 
       { 
        "id": "1", 
        "name": "Layanan dan Manfaat" 
       }, 
       { 
        "id": "2", 
        "name": "Investasi" 
       }, 
       { 
        "id": "3", 
        "name": "Perbendaharaan" 
       }, 
       { 
        "id": "4", 
        "name": "Aktuaria" 
       }    
      ], 

      "system":[ 
       { 
        "id": "5", 
        "name": "Pengumuman" 
       } 
      ] 
     } 
} 

コントローラー:

onInit: function(oEvent){ 
     var oModel = new JSONModel("metroui/module.json"); 
     this.getView().setModel(oModel); 
    }, 

    pressTileModule : function(oEvent){ 
     var sPath = oEvent.getSource().getBindingContext().getPath(); 
     var oModel = this.getView().getModel(); 
     var oContext = oModel.getProperty(sPath); 
    } 

XML:

<core:View xmlns:core="sap.ui.core" 
      xmlns:mvc="sap.ui.core.mvc" 
      xmlns="sap.m" 
      xmlns:l="sap.ui.layout" 
      xmlns:tnt="sap.tnt" 
      controllerName="metroui.MetroUI" 
      xmlns:html="http://www.w3.org/1999/xhtml"> 

      <App id="navCon"> 
       <pages> 
        <Page id="module" showHeader="false"> 
         <Panel headerText="Module"> 
          <content> 
           <l:HorizontalLayout 
            id="TileContainerModule" 
            allowWrapping="true" 
            content="{/}"> 
             <GenericTile class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout" 
              header="{name}" press="pressTileModule"> 
              <tileContent> 
               <TileContent> 
                <content> 
                 <ImageContent description="{id}" src="sap-icon://list"/> 
                </content> 
               </TileContent> 
              </tileContent> 
             </GenericTile> 
           </l:HorizontalLayout> 
          </content> 
         </Panel>  
        </Page> 
       </pages> 
      </App>  
</core:View> 

オブジェクトモジュール>(JSONから)モジュールを結合するため、コンテンツのXMLファイルに設定=」私はJSON構造を有しています{/ module/module} "と設定していますが、コンディションバインディングを設定したいので、コントローラにコンテンツセットパスJSON が必要です。 SON構造)。私はJSONファイルを読み込むときに選択をバインドする方法は? JSON構造体をコントローラに配置すると、新しいJSONモデルthis.module.moduleまたはthis.module.systemを作成できますが、XMLでcontent = "{/}"を設定しますが、ファイルJSONをロードするときにバインディングを選択できません。この問題を解決するには?

おかげで、 ボビー

答えて

0

これは私が何をするのかです。 OnInitで

ステップ1()、jsonDataは

If ('module' in jsonData.module)を使用して 'モジュール' または 'システム' を有する場合 var jsonData = $.getJSON("metroui/module.json");

ステップ2.チェックを使用してJSONオブジェクトを取得します

関連する問題