Skip to Content
0
Former Member
Aug 13, 2012 at 09:38 PM

Data binding from JSON object not working. Please let me know if any thing missing here

26 Views

<!

DOCTYPE html>


<

html><head>


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


<meta charset="UTF-8">


<title>test</title>



<script id='sap-ui-bootstrap' type='text/javascript'


src='/SAPUI5_P2/resources/sap-ui-core.js'


data-sap-ui-theme='sap_goldreflection'


data-sap-ui-libs='sap.ui.commons,sap.ui.ux3'></script>


<!-- add 'sap.ui.table' and/or other libraries if required -->



<

script>


// JSON sample data


var data = {


firstName:

"John", lastName: "Doe",


birthday: { day: 01, month: 05, year: 1982 },


address:[{ city:

"Heidelberg" }], enabled: true


};



var oModel = new sap.ui.model.json.JSONModel(); // create JSON model instance


oModel.setData(data);

// set the data for the model


sap.ui.getCore().setModel(oModel);

// assign the model to the core



var oTxt = new sap.ui.commons.TextField("txtField", {


value:

"{firstName}" // binding syntax using curly braces


});



// generic bind method bindProperty(control property, model property)


oTxt.bindProperty(

"enabled", "enabled");



oTxt.placeAt(

"content");



</

script>



</

head>


<

body class='sapUiBody'>


<div id='content'></div>


</

body>


</

html>