The SAP OData V4 model supports the following three types of data binding:
- List bindings, which represent bindings of collection types, such as
/SalesOrderList
, the type of binding instance issap.ui.model.odata.v4.ODataListBinding
. - Context binding, based on a single entity, such as
/SalesOrderList('0500000000')
, the type of binding instance issap.ui.model.odata.v4.ODataContextBinding
. - Property bindings, representing properties in an entity or complex type, such as
/ProductList('HT-1000')/Name
. The type of the binding instance issap.ui.model.odata.v4.ODataPropertyBinding
.
Although the OData V4 model itself provides some APIs, namely factory methods bindList, bindContext
and bindProperty
to create binding instances, usually, application developers will never call these methods directly , but create a binding instance in the following way.
Using the bindElement method of SAP UI5 controls
example:
oForm.bindElement("{/SalesOrderList('0500000000')}");
This example binds the form control to a specified Sales order instance, so all elements contained in the form display the instance data of the sales order in a relative binding manner.
In actual project applications, binding expressions can be more complex:
oForm.bindElement({path : "/SalesOrderList('0500000000')", parameters : {$expand : "SO_2_SOITEM", ...}, events : {dataReceived : '.onDataEvents', ...}});
The above shows how to monitor the event dataReceived
and respond to it in the event handler defined by yourself onDataEvents
.
Binding declaration in XML view
code show as below:
<Table items="{path : '/SalesOrderList', parameters : { $expand : 'SO_2_BP', $filter : 'BuyerName ge \'M\'', ...}, events : {dataReceived : '.onDataEvents', ... } }">
The above code binds the items property of the Table
control to the OData collection /SalesOrderList
. The accompanying parameter is also specified: $expand
, which is the standard syntax of OData.
For a detailed description of the binding path of OData V4, you can check its official website .
If the leading slash symbol /
is added, each resource path (relative to the service root URL, and without the query option) is a valid data binding path in this model.
For example, an entity instance with key A/B&C
can be accessed using /EMPLOYEES('A%2FB%26C')
. Note that proper URI encoding is required.
If the binding's path begins with a forward slash /
, the bindings are called absolute bindings; otherwise they are called relative bindings. The initial meaning of relative bindings is that as long as they don't have a binding context, they have no data to display.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。