Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

OData binding with SimpleForm control

$
0
0

Hi guys,

 

I'm new to SAPUI5 and trying to bind my OData properties to a SimpleForm. The simple form has to be created in a JavaScript view and has to show some properties from my entity set "General" .

According to the best practices, I created my service in the Component.js and link it to the root view:

 

createContent : function(){  var oView = sap.ui.view({  id : "app",  viewName : "view.App",  type : "JS",  viewData : { component : this }  });  var mConfig = this.getMetadata().getConfig();  var sServiceUrl = mConfig.serviceConfig.serviceUrl;  var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);  oModel.setDefaultBindingMode("TwoWay");  oView.setModel(oModel);  return oView;
}

 

Then I created my "General" controller and view. In the General.view.js I created a SimpleForm and try to bind it with the OData service:


createContent : function(oController){  var oSimpleForm = new sap.ui.layout.form.SimpleForm("sf1");  var oFormElement = new sap.ui.core.Element({  label : new sap.ui.commons.Label({ text : "Name" }),  fields :  new sap.ui.commons.TextView({ value : "{Stext}" })  });  oSimpleForm.bindElement("/General", oFormElement);  return new sap.m.Page({  title : "General",  content : [ oSimpleForm ]  });
}

Unfortunately the property binding between the property "Stext" of my entity set "General" is not working for the SimpleForm control.


When I replace my SimpleForm with a list, also in the General.view.js, it does however work:

createContent : function(oController){  var bpList = new sap.m.GrowingList("list",{  threshold : 5  });  var objectTemplate = new sap.m.ObjectListItem({  title : "{Stext}"  });  bpList.bindItems("/algemeenSet", objectTemplate);  return new sap.m.Page({  title : "titel",  content : [ bpList ]  });
}



Also when I look at the 'Network' tab in chrome developer tools, I see the GET and see the data is present in the Preview tab. The problem is getting the property to bind with the SimpleForm.


Anyone seeing what I'm doing wrong?

Many thanks in advance!












Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>