I wrote this part to bind OData information with a select controller:
var countrItems = new sap.ui.core.ListItem();
countrItems.bindProperty("key", "Land1");
countrItems.bindProperty("text", "Landx");
var CountrSelect = this.byId("CountrySelect");
CountrSelect.setModel(oModelTriptab);
CountrSelect.bindItems("/Countries", countrItems);
I would like to perform an action after the binding is complete (I want to select some default value that can change dynamically).
Attach handlers to events provided by Binding:
Those events can be applied, not only to ListBindings, but to all bindings. Note: PropertyBindings do not trigger any requests, so no
dataRequested
ordataReceived
for them.In that case, you'd attach a handler either to
change
ordataReceived
event to be notified about the "complete" binding.Compared to attaching a handler to
requestCompleted
, the above approach is more descriptive and, most importantly, binding-specific.List, m.Table, m.Tree, ...
Alternatively, UI5 offers the event
updateFinished
for Controls derived fromsap.m.ListBase
. It's similar to thechange
event, but provides more information such as an additional"Growing"
reason, actual, and total count of the entries.Use the model's
requestCompleted
event handler to perform any actions that should happen right after your model data is updated.The binding itself should be rather static (i.e. it will not change) so you'r only interested in when the data is changed
edit here's an example implemantation:
See https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.Model.html#attachRequestCompleted for more info