Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
a2fe8e763014477e87990ff50657a0d0
view on: demo kit nightly build | demo kit latest release
Composite Binding
Calculated fields enable the binding of multiple properties in different models to a single
property of a control.
The value property of a text field, for example, may be bound to a property firstName and a
property lastName in a model. The application can access these values in a formatter
function and can decide how they should be processed or combined together. If no
formatter function is specified, the values are joined together by default. You can use the
useRawValues property to specify if the parameter values in the formatter function are
formatted according to the type of the property or not.
The multiple property bindings are stored in a CompositeBinding and can be accessed by
calling the getBindings function. You can access the composite binding, for example, by
using the getBinding('value') function of the control. The composite binding has no path,
model, context, and type because it contains multiple property bindings containing the
necessary information. A composite binding may, for example, store two property bindings
which belong to different models and have different types.
If you have specified a formatter function, it is also available in the composite binding.
There are several options to create multiple bindings for a control. The syntax is very
similar to the normal single binding declaration.
Each binding is created by the specified parts and assigned information. A part must
contain the path to the property in the model and may contain additional information for
the binding, for example a type.
Constructor Declaration
1. Use binding objects to add additional parameters, for example the type:
oTxt.bindValue({
parts: [
{path: "/firstName", type: new sap.ui.model.type.String()},
{path: "/lastName"}
]
});
oTxt.bindValue({
parts: [
"/firstName",
"/lastName"
]
});
These samples also work with a relative binding path, when you use them as a template in
a list binding.
<script id="sap-ui-bootstrap"
...
data-sap-ui-bindingSyntax="complex">
</script>
<TextField value="{
path:'gender',
formatter:'.myGenderFormatter'
}
{firstName},
{lastName}
"/>
<TextField value="{
parts: [
{path:'birthday/day'},
{path:'birthday/month'},
{path:'birthday/year'}
],
formatter:'my.globalFormatter'
}"/>
• For a global type that is created with the specified format options, see the following
example: