如何通过 ID 设置 Fragment ID 和访问控制? [英] How to set Fragment ID and access controls by ID?

查看:36
本文介绍了如何通过 ID 设置 Fragment ID 和访问控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置片段 ID 并通过 ID 从控制器访问片段中的控件本身和所有其他控件?

How can I set fragment ID and access the control itself and all other controls in the fragment from the controller via ID?

<IconTabFilter id="fragOrder" key="Order Detail" text="Order Detail" >
  <content>
    <core:Fragment id="idOrderFrag" fragmentName="OrderDetail"  type="XML" />
  </content> 
</IconTabFilter>        

控制台:

console.log(" >>" + this.getView().getId("fragOrder"));
console.log(" >>" + this.getView().getId("idOrderFrag"));

推荐答案

您无法获取 Fragment 的实例,因为 Fragment 本身并未呈现,而是呈现了 Fragment 内部的控件.您只能在片段 xml 中获取呈现的控件实例.

You can not get the instance of the Fragment as the fragment itself is not rendered, the controls inside the fragment are rendered. You can only get the rendered control instances inside the fragment xml.

比如你有一个输入控件有一个id叫order_name",你可以通过下面的代码获取输入:

For example, you have a input control has an id called "order_name",you can get the input by the following code:

this.byId(sap.ui.core.Fragment.createId("idOrderFrag", "order_name"));

请参阅此处关于片段 ID 的文档.

See the documentation here about fragment ids.

这篇关于如何通过 ID 设置 Fragment ID 和访问控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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