2016-04-25 16 views
-2

ルーティングが使用されているときに私のコンテキストをsap.m.tableにバインドできません。 SplitAppでは、私はマスターページの行項目をクリックしたとき、私は今SAPUI5コンテキストでのルーティングでデータが表示されない

contextarg = decodeURIComponent(evt.getParameter("arguments").ctx);

を使用して詳細ページとコンテキストに移動し、私は

var url = "***/sap/opu/odata/SAP/ZFIRST_VENDOR_SRV"; 
    var olineOdataModel = new sap.ui.model.odata.ODataModel(url,false); 
    var rd = contextarg+ "/VENDORITEMSSet"; 
    olineOdataModel.read(rd, 
       null, 
       null, 
       false, 
       function(oData, oResponse){ 

       var oODataJSONModel = new sap.ui.model.json.JSONModel();           
       oODataJSONModel.setData(oData); 
       // store the model 
       var lineTable = sap.ui.getCore().byId("__xmlview5--lineItemTable");     
       lineTable.setModel(oODataJSONModel,"localModel"); 
       console.log(lineTable.getModel("localModel")); 

コンソール出力を示しを使用してODATAこのPARAMに合格しています

enter image description here

と私は

として、テーブルと結合行っているので、
<Table id="lineItemTable" headerText="Line Items" items="{'/results'}"> 
     <columns> 
      <Column> 
       <header> 
        <Label text="Product ID" /> 
       </header> 
      </Column> 
      <Column> 
       <header> 
        <Label text="Product Name" /> 
       </header> 
      </Column> 
      <Column> 
       <header> 
        <Label text="Product Price" /> 
       </header> 
      </Column> 
      <Column> 
       <header> 
        <Label text="Product Weight (gms)" /> 
       </header> 
      </Column> 
      <Column> 
       <header> 
        <Label text="Available From" /> 
       </header> 
      </Column> 
     </columns> 
     <ColumnListItem> 
      <cells> 
       <ObjectIdentifier title="{ProductId}" /> 
       <ObjectIdentifier title="{ProductName}" /> 
       <ObjectIdentifier title="{ProductPrc}" /> 
       <ObjectIdentifier title="{ProductWt}" /> 
       <ObjectIdentifier title="{AvailableFrom}" /> 
      </cells> 
     </ColumnListItem> 
    </Table> 

ただし、ビューにデータが表示されません。私はitems="{'results'}"items="{path:'results'}"を試しました。親切に助けてください。私はここで何をしたのですか?

答えて

1

あなたは次への結合を変更します。

items="{'localModel>/results'}" 

を、あなたの名前のモデルのエイリアスを見ることができるように追加されます。その後、テンプレートに使用しているというモデルのエイリアスを追加します。

<ColumnListItem> 
    <cells> 
     <ObjectIdentifier title="{localModel>ProductId}" /> 
     <ObjectIdentifier title="{localModel>ProductName}" /> 
     <ObjectIdentifier title="{localModel>ProductPrc}" /> 
     <ObjectIdentifier title="{localModel>ProductWt}" /> 
     <ObjectIdentifier title="{localModel>AvailableFrom}" /> 
    </cells> 
</ColumnListItem> 

の代わりに、このすべてをやってあなただけの代わりに

lineTable.setModel(oODataJSONModel,"localModel"); 
console.log(lineTable.getModel("localModel")); 

ヒントの

lineTable.setModel(oODataJSONModel); 
console.log(lineTable.getModel()); 

を使用することができます: 基本的にAJAXリクエストを実行するODataModelを作成しています。 UI5のOData + ODataModelの機能を利用するために、ComponentにODataModelをインスタンス化する方がはるかに優れたアプローチになります。 Walkthrough Tutorialは、その詳細を学ぶのに適した出発点です。

関連する問題