绑定完成后执行操作 [英] Perform Action after the Binding Is Complete

查看:36
本文介绍了绑定完成后执行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写这部分是为了将 OData 信息与 select 控制器绑定:

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).

推荐答案

使用模型的 requestCompleted 事件处理程序来执行任何应该在模型数据更新后立即发生的操作.

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

编辑这里是一个示例实现:

var that = this;
oModelTriptab.attachRequestCompleted(function(oEvent){
    var oSelect = that.byId("CountrySelect");
    oSelect.setSelectedKey("whatever");
});

参见 https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.Model.html#attachRequestCompleted了解更多信息

这篇关于绑定完成后执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆