Json.getproperty给出undefined

时间:2015-04-24 11:13:40

标签: javascript json

我有以下代码,我需要使用sap ui5 JSON Model绘制一个表。当我运行程序时,我在输出表中没有数据。我json.getProperty警告我正在获取未定义的警报输出。

<!DOCTYPE html>
<html>
<head>
 <!-- Load UI5, select gold reflection theme and the "commons" and "table"  control libraries -->
<script id="sap-ui-bootstrap"
     type="text/javascript"
      src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js"
     data-sap-ui-theme="sap_bluecrystal"
     data-sap-ui-libs="sap.ui.commons,sap.ui.table"></script>

<script>
jQuery.ajax({
    url: "/XMII/Illuminator?QueryTemplate=ZTest/QueryTemplates/table%20list&content-type=text/json",
    dataType: "json",
    success: function(data, textStatus, jqXHR) { // callback called when data is received
        var jsonModel = new sap.ui.model.json.JSONModel();
        jsonModel.loadData(data);
        sap.ui.getCore().setModel(jsonModel);

        var weatherTable = new sap.ui.table.Table({
            title : "Current Weather Details",
            visibleRowCount : 20
        });

        weatherTable.addColumn(new sap.ui.table.Column({
            label : new sap.ui.commons.Label({text : "Tablename"}),               
            template : new sap.ui.commons.TextView().bindText("TableName")                
        }));

        var oModel1 = new sap.ui.model.json.JSONModel();  

        var aData = jsonModel.getProperty("/Rowsets/Rowset/Row");            
        oModel1.setData({modelData : aData});            
        weatherTable.setModel(oModel1);  
        weatherTable.bindAggregation("rows","/modelData");  
        weatherTable.placeAt('content'); 


        var dataLayout = new sap.ui.layout.HorizontalLayout({
            id : "dataLayout", // sap.ui.core.ID                
        });

        var Tablename = new sap.ui.commons.TextView({
            id : "Tablename",
            text : '{TableName}'
        })

        dataLayout.addContent(Tablename);
        dataLayout.placeAt("content");
    }
});
</script>

</head>
<body class='sapUiBody'>
    <div id='content'></div>
</body>
</html>

0 个答案:

没有答案