2015-06-02 105 views
-1

我無法將數據綁定到列表。試過兩種方法 - 直接在視圖中綁定,也可以在控制器的onInit方法中使用read方法。 請協助。列表未綁定

查看代碼:

var oList = new sap.m.List({ 
     type:sap.m.ListType.Navigation, 
     id : this.createId("qList"), 
     template: listItems 
    }); 

    var listItems = new sap.m.ActionListItem({ 
      text:"{Quarter}", 
      id : this.createId("Q1"), 
      type:sap.m.ListType.Navigation, 
      press:function(){ 
      oController.quarterSelect(); 
     }}); 
    oList.bindItems("fullmodel>/ETQUARTERSet", listItems); 

控制器代碼:

onInit: function() { 
    this.router = sap.ui.core.UIComponent.getRouterFor(this); 

    var oModel = new sap.ui.model.odata.ODataModel("http://dewdfcto021.wdf.sap.corp:1080/sap/opu/odata/SAP/ZOC_SERVICES_SRV/"); 
    sap.ui.getCore().setModel(oModel,"fullmodel"); 

    var quartersList = this.byId("qList"); 
    var quarterItem = this.byId("Q1"); 


    var pathFilterCond = "/ETQUARTERSet"; 
    oModel.read(pathFilterCond, null, null, true, function(oData, oResponse) 
      { 
       if (oData) 
        { 
        var oJSONQuarters = new sap.ui.model.json.JSONModel(oData); 
        quartersList.setModel(oJSONQuarters); 
        quartersList.bindAggregation("items", "/Quarter", quarterItem); 
        } 
      } 

    ); 
}, 

回答

0

當你使用一個名爲模型記住,模型的名字應該在每一個綁定路徑前綴。當您綁定listItem的文本時,您錯過了模型名稱。

var listItems = new sap.m.ActionListItem({ 
      text:"{fullmodel>Quarter}", 
      id : this.createId("Q1"), 
      type:sap.m.ListType.Navigation, 
      press:function(){ 
      oController.quarterSelect(); 
     }}); 

oList.bindItems( 「fullmodel>/ETQUARTERSet」,listItems中);