Skip to Content
1
Former Member
Dec 13, 2013 at 07:26 AM

JSON data in SAPUI5

76 Views

[{"NscItem":"","SapItem":"000000000009999999","ManufacturerPart":"","Upc":"","Uom":"EA","CasePack":"","Manufacturer":"","Name":"","Description":"Unidentrified Item"},{"NscItem":"","SapItem":"000000000001003096","ManufacturerPart":"412WN","Upc":"","Uom":"CS","CasePack":"1000","Manufacturer":"0000100119","Name":"Solo Cup\/Swthrt\/Clrshield","Description":"Cup Paper Hot 12 Oz W\/Hndl Wht"}]



hey i want to call the above JSON data in a Table in SAPUI5 ...By storing this data in my local Host an call it in SAPUI5......can you please guide me ......

I used this code but not working

<html>

<head>

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<title>SAPUI5 Conditional Databinding</title>

<script src="resources/sap-ui-core.js"

type="text/javascript"

id="sap-ui-bootstrap"

data-sap-ui-libs="sap.ui.commons,sap.ui.table"

data-sap-ui-theme="sap_goldreflection">

</script>

<script>

jQuery.sap.log.setLevel(jQuery.sap.log.LogLevel['ERROR']);

// create the DataTable control

var oTable = new sap.ui.table.Table({editable:true});

// define the Table columns

var oControl = new sap.ui.commons.TextView({text:"{/NscItem}"}); // short binding notation

oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Posting"}), template: oControl }));

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

var aData =

jQuery.ajax({

url: "http://localhost/client.json", // for different servers cross-domain restrictions need to be handled

dataType: "json",

success: function(data, textStatus, jqXHR) { // callback called when data is received

oModel.setData(data); // fill the received data into the JSONModel

alert("sparta");

},

error: function(jqXHR, textStatus, errorThrown) {

alert("error");

}

});

oTable.setModel(oModel);

oTable.bindRows("/");

// finally place the Table into the UI

oTable.placeAt("dataTable");

</script>

</head>

<body class="sapUiBody">

<h1>SAPUI5 Conditional Databinding</h1>

<div id="dataTable"></div>

</body>

</html>