2016-06-16 2 views
0

xml로 만든 테이블에 동적 데이터를 바인딩하려고합니다. 그러나 나는 그것을 만들 수 없었다. 오류는 발생하지 않지만 항상 "No Data Available"을 표시합니다. 여기 내가 시도한 것이있다.동적 데이터를 sapui5의 테이블에 바인딩하는 방법은 무엇입니까?

App.view.xml : -

<sap.ui.layout:HorizontalLayout xmlns:sap.ui.layout="sap.ui.layout" id="table_layt"> 
    <sap.ui.layout:content> 
     <Table noDataText="No Data Available" id="bud_table" class="table_layt"> 
      <items></items> 
      <columns> 
       <Column id="c1"> 
       <header><Label text="Account Description" id="aclab"/></header> 
       </Column> 
       <Column id="c2"> 
       <header><Label text="Actual" id="actlab"/></header> 
       </Column> 
       <Column id="c3"> 
       <header><Label text="Budget" id="budglab"/></header> 
       </Column> 
       <Column id="c4"> 
       <header> 
       <Label text="Variance" id="valab"/></header> 
       </Column> 
      </columns> 
     </Table> 
</sap.ui.layout:content> 

App.controller.js : -

var oTable = this.getView().byId("bud_table"); 
var oTemplate = new sap.m.ColumnListItem({ 
    cells:[ 
     new sap.m.Label({ 
     text:"{AccountDesc}" 
     }), 
     new sap.m.Text({ 
     text:"{AmtActFore}" 
     }), 
     new sap.m.Text({ 
     text:"{AmtBudget}" 
     }), 
     new sap.m.Text({ 
     text:"{AmtVariance}" 
     }) 
     ] 
}); 

oTable.bindItems ("/ 루트", oTemplate);

그리고 내 데이터는 다음과 같습니다 : -

데이터

오브젝트 {루트 : 배열 [64]}

root: Array[64] 

    0: Object 

    AccountDesc: "blah" 

    AccountNo: "blah" 

    AmtActFore: "blah" 

    AmtBudget: "blah" 

    AmtVariance: "blah" 

답변

0

나는 당신이 밀고있는 부분을 놓치고 생각 모델로 데이터 :

this.getView().setModel(
    new sap.ui.model.json.JSONModel({ 
     root: [{ 
      AccountDesc: "blah", 
      AccountNo: "blah", 
      AmtActFore: "blah", 
      AmtBudget: "blah", 
      AmtVariance: "blah" 
     }] 
    })); 

자세한 내용은 this JSBin을 참조하십시오. ode, 모델 초기화 부분 포함.

+0

예! 정말 고맙습니다 !! 이제 다음 코드를 추가했습니다. ** ** it! ** var oTreeModel = new sap.ui.model.json.JSONModel(); \t \t \t \t \t oTreeModel.setData (data); \t \t \t \t \t oTable.setModel (oTreeModel); \t \t \t \t \t oTable.bindItems ("/ root", oTemplate); ' – Hari

+0

우수 Yal. 해피 : :) – jpenninkhof

관련 문제