1. JSON Model
{company : { "treefish Inc", info: { 3, }, contacts: [ { "Barbara", "873" }, { "Gerry", "734" }, { "Susan", "275" } ]} }
Access path:
/company/name/company/info/Employees/company/contacts
2. OData Model
Sap.ui.model.odata.ODataModel is not recommended, use Sap.ui.model.odata.v2.ODataModel instead.
Declaring the OData Model
1 var New Sap.ui.model.odata.v2.ODataModel ("http://services.odata.org/Northwind/Northwind.svc/"); 2 var New Sap.ui.model.odata.v2.ODataModel ({serviceurl: "Http://services.odata.org/Northwind/Northwind.svc"}) ;
Get OData Service metadata:
var ometadata = Omodel.getservicemetadata ();
Additional information can be added when requesting OData service data:
1 varOmodel =NewSap.ui.model.odata.v2.ODataModel ({2Serviceurl: "Http://services.odata.org/Northwind/Northwind.svc", 3 serviceurlparams: {4Myparam: "Value1",5MYPARAM2: "value2"6 },7 metadataurlparams: {8Myparam: "Value1",9MYPARAM2: "value2"Ten } One});
The service data is accessed when it is requested
"Http://myserver/MyService.svc/?myParam=value&myParam2=value2" This path,
The same is true when requesting metadata: (TODO)
Get Data:
1 omodel.getdata ("/customer (' ALFKI ')"); 2 omodel.getproperty ("/customer (' ALFKI ')/address");
varOData ={ProductId:999, ProductName:"MyProduct"}//POSTOmodel.create ("/products", OData, {success:mysuccesshandler, error:myerrorhandler});//GETOmodel.read ("/products (999)", {success:mysuccesshandler, error:myerrorhandler});//PUTvarOData ={ProductId:999, ProductName:"Myproductupdated"}omodel.update ("/products (999)", OData, {success:mysuccesshandler, error:myerrorhandler});//DELETEOmodel.Delete("/products (999)", {Success:mysuccesshandler, error:myerrorhandler});
Omodel automatically refresh after the change is complete
Omodel.setrefreshafterchange (FALSE); Turn off automatic refresh
Todo
3. XML Model
SAP Ui5-data Model