admin管理员组文章数量:1418427
I am currently parsing json and displaying the data in a table control using sapui5,but i am unable to parse inner objects values
CODE:
<!DOCTYPE html>
<html><head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<title>Table example</title>
<!-- Load UI5, select gold reflection theme and the "mons" and "table" control libraries -->
<script id='sap-ui-bootstrap' type='text/javascript'
src='resources/sap-ui-core.js'
data-sap-ui-theme='sap_goldreflection'
data-sap-ui-libs='sap.uimons,sap.ui.table'></script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.uimons.TextView({text:"{ments/data/from/username}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.uimons.Label({text: "Group"}), template: oControl }));
var oControl = new sap.uimons.TextView({text:"{ments/data/from/id}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.uimons.Label({text: "Group Text"}), template: oControl }));
var oModel = new sap.ui.model.json.JSONModel();
var aData =
jQuery.ajax({
url: "", // for different servers cross-domain restrictions need to be handled
dataType: "json",
success: function(data, textStatus, jqXHR) { // callback called when data is received
var JsonData = data;
oModel.setData(JsonData); // fill the received data into the JSONModel
alert("sparta");
},
error: function(jqXHR, textStatus, errorThrown) {
alert("error");
}
});
// create a JSONModel, fill in the data and bind the Table to this model
// oModel.setData(aData);
oTable.setModel(oModel);
oTable.bindRows("/data");
// finally place the Table into the UI
oTable.placeAt("content");
</script>
</head>
<body class='sapUiBody'>
<div id='content'></div>
</body>
</html>
How do i fetch the inner element values such as username and id etc..
I am currently parsing json and displaying the data in a table control using sapui5,but i am unable to parse inner objects values
CODE:
<!DOCTYPE html>
<html><head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<title>Table example</title>
<!-- Load UI5, select gold reflection theme and the "mons" and "table" control libraries -->
<script id='sap-ui-bootstrap' type='text/javascript'
src='resources/sap-ui-core.js'
data-sap-ui-theme='sap_goldreflection'
data-sap-ui-libs='sap.ui.mons,sap.ui.table'></script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.mons.TextView({text:"{ments/data/from/username}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.mons.Label({text: "Group"}), template: oControl }));
var oControl = new sap.ui.mons.TextView({text:"{ments/data/from/id}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.mons.Label({text: "Group Text"}), template: oControl }));
var oModel = new sap.ui.model.json.JSONModel();
var aData =
jQuery.ajax({
url: "https://api.instagram./v1/media/popular?client_id=d6ff37e000de4fc7882e4e5fccfff236", // for different servers cross-domain restrictions need to be handled
dataType: "json",
success: function(data, textStatus, jqXHR) { // callback called when data is received
var JsonData = data;
oModel.setData(JsonData); // fill the received data into the JSONModel
alert("sparta");
},
error: function(jqXHR, textStatus, errorThrown) {
alert("error");
}
});
// create a JSONModel, fill in the data and bind the Table to this model
// oModel.setData(aData);
oTable.setModel(oModel);
oTable.bindRows("/data");
// finally place the Table into the UI
oTable.placeAt("content");
</script>
</head>
<body class='sapUiBody'>
<div id='content'></div>
</body>
</html>
How do i fetch the inner element values such as username and id etc..
Share Improve this question edited Feb 5, 2014 at 5:56 Jasper_07 2,4732 gold badges19 silver badges23 bronze badges asked Jun 10, 2013 at 10:45 vinvin 1,2585 gold badges20 silver badges33 bronze badges2 Answers
Reset to default 1Try something like
var oControl = new sap.ui.mons.TextView().bindProperty("text", "user/usernme");
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.mons.Label({text: "User Name"}), template: oControl}));
var oControl = new sap.ui.mons.TextView().bindProperty("text", "user/id");
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.mons.Label({text: "UserID"}), template: oControl}));
https://sapui5.hana.ondemand./sdk/#docs/guide/JSONModel.html
var arr = oModel.getData();
Using this you get the data for that model, then you can loop through the data or parse it.
本文标签: javascriptHow to parse json using sapui5Stack Overflow
版权声明:本文标题:javascript - How to parse json using sapui5 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745277755a2651278.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论