on ‎2019 Feb 17 11:56 AM
Hi all,
I wonder when I need the classes getBindingContext or getBinding in context of a sap.ui.table.Table.
In which use cases do I need this?
Many thanks
Regards
Mario
Request clarification before answering.
Hi Mario Mueller,
It's there in the documentation only.. If you go to the sap.ui.table.Table in api referece(UI5 SDK), search for getBinding.. That method will be inherited from ManagedObject. Clikcing on it will take you to the managedObject class.

The documentation itself is pretty self explanatory.
getBinding will give you the property & aggregation binding info done to that control
For example:
1. If you binded the "rows" aggregation to a model, then calling the oTable.getBinding("rows") will give you the binding information of the "rows" aggregation. similar we can do to all properties of the controls.
It will give you a lot other details, check: sap.ui.model.Binding sub classes.
getBindingContext will give you the binding context you applied on a control (element binding details)
If you do an element binding (context binding) for a control, then using the getBindingContext for a control will return you the context details that were applied for a control.
For example:
1. If you did the elemnt Binding for a view and request for this.getView().getBindingContext(modelName) will give you the details of the binding you have done on the control, for example path, or It will give you the data that is requested by the control when you did the element binding.
2. If you using the ui.table then the array of data you are passing to the rows (rows="{data>/products}" will result in multiple rows of the table. Internally sap ui5 apis will do a context binding for the every row that is generated. So when you use the event handler method on the item click, then you can call item.getBindingContext(), which will return you the bindingContext details for the row. you can also do item.getBindingContext().getObject() for the data.
https://ui5.sap.com/#/api/sap.ui.base.ManagedObject/methods/getBinding
If you are new to UI5, do the walkthrough section in SDK atleast 2 times which has more than enough information to get you started into UI5 🙂 Happy coding!
BR,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.