Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Problem mit Binding

$
0
0

Hello All,

 

I have some problem with Binding - Can someone help ?

Table is displayed without data.

Thanks in Advance,

Amyn

 

 

 

Code of Index.html :

 

<!DOCTYPE html>   
<html>   
<head>   
<!-- Added charset='utf-8' to handle data in various langauges -->   
<meta http-equiv='X-UA-Compatible' content='IE=edge' charset='utf-8' />   
<title>Stock</title>   
<!-- Load UI5, select gold reflection theme and the "commons" and "table" control libraries -->   
<script id='sap-ui-bootstrap' type='text/javascript'   
          src='resources/sap-ui-core.js' data-sap-ui-theme='sap_platinum'   
          data-sap-ui-libs='sap.ui.commons,sap.ui.table'></script>   
                                   <script type="text/javascript"> 
         //Create an instance of the table control
           var oTable = new sap.ui.table.Table({ title : "Artikel" });   
         //Define the columns and the control templates to be used
           oTable.addColumn(new sap.ui.table.Column({   
               label : new sap.ui.commons.Label({ text : "Material" }),   
//              template : new sap.ui.commons.TextView().bindProperty("Matnr", "Matnr"),
                template: new sap.ui.commons.TextView({text:"{Material}"}),
                 width : "50px" }));  
                              
               var oModel = new sap.ui.model.json.JSONModel(); 

 

             
               var url = 'http://abc.com:8026/sap/opu/odata/SAP/Z_AM_TEST_SRV/MaterialSet';  
                        $.ajax({  
                                 url : url,   
                                 jsonpCallback : 'getJSON',   
                                 contentType : "application/json",   
                                 dataType : 'jsonp', 
                                 success : function(data) {   
                                
                   oModel.setData(data);   
                   sap.ui.getCore().setModel(oModel);   
                   //Create a model and bind the table rows to this model
                   var oModel1 = new sap.ui.model.json.JSONModel();   
                   //Get the material array table from MaterialSet object
                   var aData = oModel.getProperty("d/MaterialSet");   
//                  oModel1.setData({ modelData : aData });   
                   oModel1.setData({ modelData : [ {"Material": ""}] });    
                   oTable.setModel(oModel1);
                                             }   
                      });   
                      
      oTable.bindRows("/modelData");   
      oTable.placeAt('content');   
// https://scn.sap.com/thread/3401770              
            </script>   
</head>   
    <body class='sapUiBody'>   
       <div id='content'></div>   
   </body>   
      
   </html> 

Viewing all articles
Browse latest Browse all 6178

Trending Articles