on 09-22-2015 10:06 AM
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> |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta charset="UTF-8">
<title>Hello World App</title>
<script src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js" type="text/javascript"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.ui.commons,sap.ui.table">
</script>
<script type="text/javascript">
var oTable = new sap.ui.table.Table({ title : "Artikel" });
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({ text : "Material" }),
template: new sap.ui.commons.TextView({text:"{matnr}"}),
width : "50px" }));
var oModel = new sap.ui.model.json.JSONModel({
d : [ { matnr : "Test" } ]
});
oTable.setModel(oModel);
oTable.bindRows("/d/");
oTable.placeAt('content');
</script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>
If you take this example you will be able to solve your problem. Take care about the binding path and which model you set
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
WHY do use jsonmodel to laod odata?????
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post error in browser's console?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Could you please provide us the JSON output file.
Generally with JSon the result set is something like : "/d/results/" whereas you use :
var aData = oModel.getProperty("d/MaterialSet");
Maybe this is the issue.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Name Name Entity type
MaterialSet Material
And Metadata:
-<EntityType sap:content-version="1" Name="Material">
-<Key>
<PropertyRef Name="Matnr"/>
</Key>
<Property Name="Matnr" sap:label="Material" MaxLength="18" Nullable="false" Type="Edm.String"/>
<Property Name="Maktx" sap:label="Bezeichnung" MaxLength="40" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false"/>
</EntityType>
Thanke for your Help !
User | Count |
---|---|
76 | |
9 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.