SAP UI5 Data binding - SAP UI5

What is data binding in SAP UI5?

Data binding concept in SAP UI5 is used to update the data automatically. It helps to binding the data with the controls that holds the application data. It allows you to bind data with simple controls like text field, simple button to application data, and data is automatically updated when there is a new value.

You can use two-way data binding to update the application when the value of bound control changes. The value can be changed via different methods, like user input, etc.
data_binding_concept
In SAP UI5, different data models can be used for data binding. These data models support different features −

JSON Model

JSON model is used to bind JavaScript objects to controls. This is suitable for small data sets as it is a client-side model. It doesn’t provide any mechanism for server side paging or loading.
Key features include −
  • JSON model for data binding supports data in JavaScript notation format.
  • It supports two-way data binding.
Creating a model instance –

XML Model

XML model of data binding helps to bind the data controls to XML data. It is used for clientside objects and for small data sets. There is no separate mechanism for server-side paging or loading.
Key features include −
  • XML model of data binding supports XML data.
  • It also supports two-way data binding.
Creating a model instance –

OData Model

OData model is a server-side model which includes complete server data at the server side. Here only client side can see rows and fields and you cannot see sorting and filtering at the client side. There is a need to send this request to the server to complete these tasks.
Data binding in OData model is one way but you can enable two-way binding using experimental write support.
Key features include −
  • OData model of data binding supports Odata compliant data.
  • This data model allows you to create OData requests and handle responses.
  • It supports experimental two-way binding.
Creating a model instance –

Assigning the Model

You can use the setModel method to assign the model to specific controls or core.
To bind a model to view –
To bind a model to a control –
You can bind the properties of a control to model properties. You can bind the properties of a model to a control using bindproperty method –

Aggregation Binding

You can use aggregation binding to bind a collection of values like binding multiple rows to a table. To use aggregation, you have to use a control that acts as a template.
You can define aggregation binding using bindAgregation method.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAP UI5 Topics