2017-10-20 30 views
0

我有一個包含子「問題」(輸入框)的面板(分類)。SAPUI5 - 使用_each循環呈現內容的問題

面板顯示正常,但每個面板內容:屬性可以包含更多的一個問題。

var oPanel = new sap.m.Panel({ 
      expandable: true, 
      expanded: false, 
      headerText: oData.results[0].CategoryDesc, 
      id: "Panel" + index, 
      content: _.each(oViewData.categories, function(result, index2) { 
       new sap.m.Input("iCategory" + index + index2, {    
      }); 
     }) 
    }); 
    oPanel.placeAt("panelContent"); 

我檢索數據正常,但內容不會呈現。我收到錯誤消息:

The renderer for class sap.ui.core.Control is not defined or does not define a render function! Rendering of __control0 will be skipped! - 

是否有可能在內容屬性中使用_each(underscoreJs)?如果不是,我的替代品是什麼?

回答

1

,你可以把你的數據到一個數組,並在內容區域使用它:

var oPanelContent = []; 

_.each(oViewData.categories, function(result, index2) { 
    oPanelContent.push(new sap.m.Input("iCategory" + index + index2, {    
    }) 
); 


var oPanel = new sap.m.Panel({ 
      expandable: true, 
      expanded: false, 
      headerText: oData.results[0].CategoryDesc, 
      id: "Panel" + index, 
      content: oPanelContent 
     }) 
    }); 
    oPanel.placeAt("panelContent"); 
+0

與addContent解決:) –